Skip to content

Instantly share code, notes, and snippets.

@rpassis
Created July 11, 2017 19:26
Show Gist options
  • Save rpassis/0c335502993ef6f8ee51f8b500e76782 to your computer and use it in GitHub Desktop.
Save rpassis/0c335502993ef6f8ee51f8b500e76782 to your computer and use it in GitHub Desktop.
Differentiates between dev, Testflight/AdHoc and appStore environments
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