// AppFlavor.swift — which app this build is: CottonDB or Cotton Dev.//// One source tree builds two apps that sit side by side on one iPhone and one// Mac and never touch each other's data: the real CottonDB, whose identity is// frozen, and Cotton Dev, which every local build, test and simulator run// produces. The build stamps `CottonFlavor` into every Info.plist// (`project.yml`'s `COTTON_FLAVOR`, `scripts/build-app.sh --flavor`); this// type reads it and holds every identifier Swift names by flavor. The Rust// core's half — the data folder, the port, the relay-name rule, a server's// flavor — is `crates/cotton-core/src/flavor.rs`, handed the same word at open.//// UNSTAMPED IS DEV. Only the exact word `real` is the real app: a build that// forgot to say which it is lands on the side that cannot reach the real// household. `AppFlavorTests` is the guard that no dev identifier is a real one.importFoundationpublicenumAppFlavor: String, CaseIterable, Sendable {case realcase dev/// The Info.plist key every bundle in the family carries.publicstaticlet infoKey = "CottonFlavor"/// What a bundle declares. Anything but `real` is `.dev`.publicstaticfunc of(_ bundle: Bundle) -> AppFlavor { declared(bundle.object(forInfoDictionaryKey: infoKey) as? String) }/// A declared word, read the one way.publicstaticfunc declared(_ value: String?) -> AppFlavor { value?.trimmingCharacters(in: .whitespacesAndNewlines) == "real" ? .real : .dev }/// This process's flavor.publicstaticlet current: AppFlavor = of(.main)// MARK: - The iPhone/// The phone app's bundle id; the share extension appends/// `.share-extension` (`project.yml`).publicvar phoneAppID: String {switchself {case .real: return"com.cottondb.cotton"case .dev: return"com.cottondb.cotton.dev" } }/// `group.<phone app id>`.publicvar phoneAppGroup: String { "group." + phoneAppID }/// The phone's Keychain service — the device seed, the vault key and every/// secret `SecretStore` keeps. The phone's access group already differs by/// bundle id; the service differs too so nothing depends on that alone.publicvar phoneKeychainService: String { phoneAppID }// MARK: - The Mac/// CottonDB for Mac's bundle id.publicvar macBundleID: String {switchself {case .real: return"com.decemberfm.cottondb.mac"case .dev: return"com.decemberfm.cottondb.mac.dev" } }/// The Mac's app group — team-prefixed (see `CottonDefaults.macAppGroup`).publicvar macAppGroup: String {switchself {case .real: return"M7V3QVXZQH.com.decemberfm.cotton"case .dev: return"M7V3QVXZQH.com.decemberfm.cotton.dev" } }/// The Mac's Keychain service. The Mac's login keychain is shared by every/// app the person runs, so this is what keeps the two apps' device keys,/// relay identities and vault keys apart.publicvar macKeychainService: String {switchself {case .real: return"com.decemberfm.cotton.mac"case .dev: return"com.decemberfm.cotton.mac.dev" } }/// The session host's launchd label (and its plist's file name, `.plist`).publicvar sessionHostLabel: String {switchself {case .real: return"com.decemberfm.cotton.session-host"case .dev: return"com.decemberfm.cotton.dev.session-host" } }/// The Mac app's name — its bundle's file name without `.app`.publicvar macAppName: String {switchself {case .real: return"CottonDB"case .dev: return"Cotton Dev" } }/// The one place the Mac app registers its login item and agent from.publicvar installedPath: String { "/Applications/\(macAppName).app" }/// The Mac's data folder's name under the home folder. The Rust core/// decides the path (`Flavor::home_data_dir`); this is for sentences.publicvar dataFolderName: String {switchself {case .real: return"CottonDB"case .dev: return"CottonDev" } }// MARK: - Both/// The URL scheme every deep link carries.publicvar urlScheme: String {switchself {case .real: return"tinmen-cotton"case .dev: return"cottondev" } }/// The name a person reads on the phone's home screen.publicvar displayName: String {switchself {case .real: return"Cotton"case .dev: return"Cotton Dev" } }}