This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import Foundation | |
| @resultBuilder | |
| struct DebugPrinterContentBuilder { | |
| static func convertItems(_ items: [Any]) -> [String] { | |
| items.map { item in | |
| var buffer: String = "" | |
| print(item, terminator: "", to: &buffer) | |
| return buffer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // See: https://stackoverflow.com/a/70595187/8249180 | |
| actor ImageDownloader { | |
| private enum CacheEntry { | |
| case inProgress(Task<Image, Error>) | |
| case ready(Image) | |
| } | |
| private var cache: [URL: CacheEntry] = [:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let userAgent: String = { | |
| var components: [String] = [] | |
| if let appName = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? Bundle.main.infoDictionary?["CFBundleIdentifier"] as? String { | |
| let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "" | |
| components.append("\(appName)/\(version)") | |
| } | |
| // Replace Your bundle name | |
| let libraryBundle: Bundle? = Bundle(for: <#Your Class Name#>.self) |