diff --git a/Utilities/Utilities/_Utils/Installation.swift b/Utilities/Utilities/_Utils/Installation.swift index 591c41160..fd767dbaa 100644 --- a/Utilities/Utilities/_Utils/Installation.swift +++ b/Utilities/Utilities/_Utils/Installation.swift @@ -15,19 +15,30 @@ public class Installation { case appStore case jailBroken // potentially side-loaded } - + // This is private because the use of 'appConfiguration' is preferred. private static let isTestFlight = Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" - + + private static let isAppStore = { + // Keep this code for reference. In case "sandboxReceipt" changes in later iOS + if let receipt: URL = Bundle.main.appStoreReceiptURL { + var error: NSError? + if (receipt as NSURL).checkResourceIsReachableAndReturnError(&error), error == nil { + return true + } + } + return false + }() + // This can be used to add debug statements. static var isDebug: Bool { #if DEBUG - return true + return true #else - return false + return false #endif } - + private static var isJailBroken: Bool = { #if targetEnvironment(simulator) return false @@ -54,9 +65,8 @@ public class Installation { } #endif }() - + public static var source: Source { - return .appStore if isJailBroken { return .jailBroken } else if isDebug { @@ -67,7 +77,7 @@ public class Installation { return .appStore } } - + public static var isSimulator: Bool = { #if targetEnvironment(simulator) return true diff --git a/Utilities/Utilities/_Utils/_FeatureFlags/CompositeFeatureFlagsProvider.swift b/Utilities/Utilities/_Utils/_FeatureFlags/CompositeFeatureFlagsProvider.swift index cdfe2ad87..039bf9529 100644 --- a/Utilities/Utilities/_Utils/_FeatureFlags/CompositeFeatureFlagsProvider.swift +++ b/Utilities/Utilities/_Utils/_FeatureFlags/CompositeFeatureFlagsProvider.swift @@ -58,9 +58,9 @@ public class CompositeFeatureFlagsProvider: NSObject & FeatureFlagsProtocol { public func flag(feature: String?) -> Any? { switch Installation.source { - case .appStore, .jailBroken, .testFlight: + case .appStore, .jailBroken: return remote?.flag(feature: feature) - case .debug: + case .debug, .testFlight: if let localFlag = local?.flag(feature: feature) { return localFlag } else { diff --git a/dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift b/dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift index 3f4af3708..c9f8689dc 100644 --- a/dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift +++ b/dydx/dydxStateManager/dydxStateManager/AbacusStateManager.swift @@ -153,8 +153,10 @@ public final class AbacusStateManager: NSObject { switch Installation.source { case .appStore: deployment = "MAINNET" - case .testFlight, .debug, .jailBroken: + case .debug, .jailBroken: deployment = "TESTNET" + case .testFlight: + deployment = "TESTFLIGHT" } appConfigs = AppConfigs.companion.forApp }