Cotton code
29 lines · 1.0 KB · SwiftRaw
// What this phone says about itself when a database files it in its device// list: its name and the build it runs. Read by the gate's ask (the database// the core starts on a device holding none) and by the personal object's// connect.import CottonKitimport Foundation#if canImport(UIKit)import UIKit#endifpublic enum ThisPhone {    /// The build this phone is running, as the device list records it. ONE    /// reader of the bundle, so a screen naming a version reads it here rather    /// than spelling a plist key of its own.    public static func appVersion() -> String {        CottonConfig.bundleVersionLabel ?? ""    }    /// What this phone is called until the person edits it.    public static func deviceName() -> String {        let name = UIDevice.current.name.trimmingCharacters(in: .whitespacesAndNewlines)        return name.isEmpty ? HostNoun.product : String(name.prefix(nameMax))    }    /// The longest a device name may be — in UTF-16 code units, which is what    /// the server counts.    public static let nameMax = 80}