Created
July 11, 2017 19:26
-
-
Save rpassis/0c335502993ef6f8ee51f8b500e76782 to your computer and use it in GitHub Desktop.
Differentiates between dev, Testflight/AdHoc and appStore environments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// Important: Ensure a DEBUG flag is set under OTHER SWIFT FLAGS (Debug environment only) | |
enum AppConfig: String { | |
case debug = "Debug" | |
case testFlight = "TestFlight" | |
case appStore = "Appstore" | |
private static var isTestFlight: Bool { | |
return Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" | |
} | |
private static var isDebug: Bool { | |
#if DEBUG | |
return true | |
#else | |
return false | |
#endif | |
} | |
static var environment: AppConfig { | |
if isDebug { | |
return .debug | |
} else if isTestFlight { | |
return .testFlight | |
} else { | |
return .appStore | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment