Add app distribution detection and bump remoteFormEvent method ID
- Add `AppDistribution` enum to `AppInfo.swift` that detects simulator, development, TestFlight, Ad Hoc, and App Store builds at runtime - Display distribution type in the settings footer version label - Bump `remoteFormEvent` server method ID from 20 to 21 (comment range updated to 9..20 accordingly) This fixes the client to work with the game server again and allows it to determine the install method.
This commit is contained in:
parent
25bb6d1b54
commit
5a7fa843fd
3 changed files with 32 additions and 3 deletions
|
|
@ -4,4 +4,33 @@ enum AppInfo {
|
|||
static let name = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String ?? "KDChat"
|
||||
static let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "–"
|
||||
static let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "–"
|
||||
static let distribution = AppDistribution.current
|
||||
static let testFlightURL: URL? = nil // TODO: set when TestFlight is configured
|
||||
}
|
||||
|
||||
enum AppDistribution: String {
|
||||
case development = "Development"
|
||||
case simulator = "Simulator"
|
||||
case testFlight = "TestFlight"
|
||||
case appStore = "App Store"
|
||||
case adHoc = "Ad Hoc"
|
||||
|
||||
static var current: AppDistribution {
|
||||
#if targetEnvironment(simulator)
|
||||
return .simulator
|
||||
#else
|
||||
#if DEBUG
|
||||
return .development
|
||||
#else
|
||||
if let receiptURL = Bundle.main.appStoreReceiptURL,
|
||||
receiptURL.lastPathComponent == "sandboxReceipt" {
|
||||
return .testFlight
|
||||
}
|
||||
if Bundle.main.path(forResource: "embedded", ofType: "mobileprovision") != nil {
|
||||
return .adHoc
|
||||
}
|
||||
return .appStore
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ enum ServerMethod: Int32 {
|
|||
case leaveGame = 5
|
||||
// 6 = TimeSync, 7 = RequestProfile
|
||||
case directMessage = 8
|
||||
// 9..19 = game-specific methods
|
||||
case remoteFormEvent = 20
|
||||
// 9..20 = game-specific methods
|
||||
case remoteFormEvent = 21
|
||||
}
|
||||
|
||||
// MARK: - Client Methods (server -> client)
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ struct SettingsView: View {
|
|||
}
|
||||
|
||||
Section {
|
||||
Text("\(AppInfo.name) \(AppInfo.version) (\(AppInfo.build))")
|
||||
Text("\(AppInfo.name) \(AppInfo.version) (\(AppInfo.build)) \(AppInfo.distribution.rawValue)")
|
||||
.foregroundStyle(.secondary)
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue