diff --git a/Meshtastic/Extensions/Bundle.swift b/Meshtastic/Extensions/Bundle.swift index 84353a51..0bb62acf 100644 --- a/Meshtastic/Extensions/Bundle.swift +++ b/Meshtastic/Extensions/Bundle.swift @@ -19,4 +19,8 @@ extension Bundle { // public var appVersionShort: String { getInfo("CFBundleShortVersion") } fileprivate func getInfo(_ str: String) -> String { infoDictionary?[str] as? String ?? "⚠️" } + + public var isTestFlight: Bool { + return appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" + } } diff --git a/Meshtastic/MeshtasticApp.swift b/Meshtastic/MeshtasticApp.swift index aa16b57a..f7e07099 100644 --- a/Meshtastic/MeshtasticApp.swift +++ b/Meshtastic/MeshtasticApp.swift @@ -44,8 +44,13 @@ struct MeshtasticAppleApp: App { #if !targetEnvironment(macCatalyst) #if DEBUG - environment = "TestFlight" + environment = "Local" +#else + if Bundle.main.isTestFlight { + environment = "TestFlight" + } #endif + Datadog.initialize( with: Datadog.Configuration( clientToken: clientToken, @@ -99,10 +104,10 @@ struct MeshtasticAppleApp: App { // Initialize map data manager MapDataManager.shared.initialize() - #if DEBUG +#if DEBUG // Show tips in development try? Tips.resetDatastore() - #endif +#endif if !UserDefaults.firstLaunch { // If this is first launch, we will show onboarding screens which // Step through the authorization process. Do not start discovery diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index d77445d0..7ee390cd 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -13,6 +13,7 @@ struct AppSettings: View { @State private var isPresentingCoreDataResetConfirm = false @State private var isPresentingDeleteMapTilesConfirm = false @State private var purgeStaleNodes: Bool = false + @State private var showAutoConnect: Bool = false @AppStorage("purgeStaleNodeDays") private var purgeStaleNodeDays: Double = 0 @AppStorage("environmentEnableWeatherKit") private var environmentEnableWeatherKit: Bool = true @AppStorage("enableAdministration") private var enableAdministration: Bool = false @@ -47,12 +48,13 @@ struct AppSettings: View { Text("Provide anonymous usage statistics and crash reports.") .foregroundStyle(.secondary) .font(.caption) -#if DEBUG - Toggle(isOn: autoconnectBinding) { - Label("Automatically Connect", systemImage: "app.connected.to.app.below.fill") + + if showAutoConnect { + Toggle(isOn: autoconnectBinding) { + Label("Automatically Connect", systemImage: "app.connected.to.app.below.fill") + } + .tint(.accentColor) } - .tint(.accentColor) -#endif } Section(header: Text("environment")) { VStack(alignment: .leading) { @@ -73,6 +75,13 @@ struct AppSettings: View { .onFirstAppear { purgeStaleNodes = purgeStaleNodeDays > 0 Logger.services.info("ℹ️ Purge Stale Nodes toggle initialized to \(purgeStaleNodes)") +#if DEBUG + showAutoConnect = true +#else + if Bundle.main.isTestFlight { + showAutoConnect = true + } +#endif } .onChange(of: purgeStaleNodes) { _, newValue in purgeStaleNodeDays = purgeStaleNodeDays > 0 ? purgeStaleNodeDays : 7