Build Number Hash Alignment

Nucleic-Session: F8E9CC32-59CC-4022-B42C-0B0694C57F42
Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
2026-07-02 21:51:55 -07:00
co-authored by Nucleic
parent c6175b7185
commit 1ec8871536
@@ -32,11 +32,16 @@ enum BuildChannel {
}
/// Build identity for the running app: which channel it came from and its build label.
/// The Mac embeds a git commit via a prebuild plugin; the iOS build number is derived from
/// `git rev-list --count` at archive time (scripts/ios-release.sh), so `CFBundleVersion`
/// plays the same role here.
/// Both platforms show the short git commit: the Mac embeds it via a prebuild plugin, and
/// here the NucleicRemote target's "Stamp git commit into Info.plist" build phase writes
/// `git rev-parse --short HEAD` into the `NucleicCommit` Info.plist key. Falls back to
/// `CFBundleVersion` (the `git rev-list --count` build number from scripts/ios-release.sh)
/// when git isn't available.
struct BuildInfo {
let channel: BuildChannel
/// The short git commit the binary was built from (e.g. "a1b2c3d", "+" suffix when the
/// tree was dirty) — matching the Mac's banner. Falls back to `CFBundleVersion` / "local"
/// if the build phase couldn't resolve a hash.
let buildLabel: String
/// `CFBundleShortVersionString` when present, else `nil`.
let version: String?
@@ -47,7 +52,13 @@ struct BuildInfo {
init() {
let info = Bundle.main.infoDictionary
version = info?["CFBundleShortVersionString"] as? String
buildLabel = (info?["CFBundleVersion"] as? String) ?? "local"
// Prefer the stamped git commit (mirrors the Mac's GitCommit.hash); an empty or
// "unknown" value means git wasn't available at build time, so fall back to the
// bundle build number.
let commit = info?["NucleicCommit"] as? String
buildLabel = commit.flatMap { $0.isEmpty || $0 == "unknown" ? nil : $0 }
?? (info?["CFBundleVersion"] as? String)
?? "local"
channel = Self.detectChannel(stamped: info?["NucleicChannel"] as? String)
}