Cotton code
28 lines · 1.0 KB · SwiftRaw
// The screens' own resource bundle: the definitions and their synthetic// records, the places, the licences — what only `CottonUI` reads. The look's// pictures, faces, palette and themes are `CottonPaper`'s bundle// (`CottonResources`), and this one is found the same way: `Bundle.module` on// the phone, by path on the Mac (`CottonResources.locate`).import Foundationenum CottonUIResources {    /// The SwiftPM resource bundle's name: `<package>_<target>.bundle`.    static let bundleName = "Cotton_CottonUI.bundle"    /// This module's resource bundle, wherever this build put it — or nil    /// when this build has none to find.    static let bundle: Bundle? = {        #if canImport(UIKit)            return Bundle.module        #else            return locate(from: Bundle.main) ?? locate(from: Bundle(for: Marker.self))        #endif    }()    private final class Marker {}    static func locate(from main: Bundle) -> Bundle? {        CottonResources.locate(bundleName, from: main)    }}