Created
February 27, 2021 14:57
-
-
Save cafielo/061c3c940095203b1f216218c5c47b36 to your computer and use it in GitHub Desktop.
Env Configuration
This file contains hidden or 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
enum Env: String { | |
case debug | |
case testFlight | |
case appStore | |
} | |
struct App { | |
struct Folders { | |
static let documents: NSString = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString | |
static let temporary: NSString = NSTemporaryDirectory() as NSString | |
} | |
static let version: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String | |
static let build: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as! String | |
// This is private because the use of 'appConfiguration' is preferred. | |
private static let isTestFlight = Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" | |
// This can be used to add debug statements. | |
static var isDebug: Bool { | |
#if DEBUG | |
return true | |
#else | |
return false | |
#endif | |
} | |
static var env: Env { | |
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