mirror of
https://github.com/passepartoutvpn/passepartout-apple.git
synced 2025-02-16 12:52:11 +00:00
Polish bundleConfig with strong type checking
This commit is contained in:
parent
3e8a49c970
commit
a442603696
@ -27,10 +27,6 @@ import Foundation
|
||||
import UniformTypeIdentifiers
|
||||
import SwiftyBeaver
|
||||
|
||||
extension Constants {
|
||||
private static let bundleConfig = Bundle.main.infoDictionary?["com.algoritmico.Passepartout.config"] as? [String: Any]
|
||||
}
|
||||
|
||||
extension Constants {
|
||||
enum App {
|
||||
static var appId: String {
|
||||
@ -40,9 +36,9 @@ extension Constants {
|
||||
return identifier
|
||||
}
|
||||
|
||||
static let appStoreId = bundleConfig?["appstore_id"] as? String ?? "DUMMY_appstore_id"
|
||||
static let appStoreId: String = bundleConfig("appstore_id")
|
||||
|
||||
static let appGroupId = bundleConfig?["group_id"] as? String ?? "DUMMY_group_id"
|
||||
static let appGroupId: String = bundleConfig("group_id")
|
||||
|
||||
static let isBeta: Bool = {
|
||||
Bundle.main.isTestFlight
|
||||
@ -57,7 +53,7 @@ extension Constants {
|
||||
|
||||
return testAppType
|
||||
}
|
||||
if let infoValue = bundleConfig?["app_type"] as? Int,
|
||||
if let infoValue: Int = bundleConfig("app_type"),
|
||||
let testAppType = ProductManager.AppType(rawValue: infoValue) {
|
||||
|
||||
return testAppType
|
||||
|
@ -26,6 +26,16 @@
|
||||
import Foundation
|
||||
|
||||
enum Constants {
|
||||
static func bundleConfig<T>(_ key: String, in bundle: Bundle? = nil) -> T {
|
||||
guard let config = (bundle ?? .main).infoDictionary?["com.algoritmico.Passepartout.config"] as? [String: Any] else {
|
||||
fatalError("Unable to find config bundle")
|
||||
}
|
||||
guard let value = config[key] as? T else {
|
||||
fatalError("Missing \(key) from config bundle")
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
enum Global {
|
||||
static let appName = "Passepartout"
|
||||
|
||||
|
@ -27,7 +27,7 @@ import Foundation
|
||||
|
||||
extension Constants {
|
||||
enum Launcher {
|
||||
static let appId = "com.algoritmico.ios.Passepartout"
|
||||
static let appId: String = bundleConfig("app_id")
|
||||
|
||||
private static let appPath: String = {
|
||||
let path = Bundle.main.bundlePath as NSString
|
||||
|
@ -20,5 +20,10 @@
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
|
||||
<key>com.algoritmico.Passepartout.config</key>
|
||||
<dict>
|
||||
<key>app_id</key>
|
||||
<string>$(CFG_APP_ID)</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
Loading…
Reference in New Issue
Block a user