I have xcode project in swift with 3 schemes.
I have plist files for each of that schemes, in that plist file i have constants values like fontname, color and logo name, etc. Supose i have 3 schemes 1. Banana 2. Orange 3. Apple
So i for these all scheme i have plist file names as 1. BananaScheme 2. OrangeScheme 3. AppleScheme
Now i have one swift file called as SchemeConfig in this file i have to read this plist file and returns constant's value.
To read plist file i have one method as below
private func getConfigFile() -> [String: Any]? {
var configFileName: String = ""
#if Banana
configFileName = "BananaScheme"
#elseif Orange
configFileName = "OrangeScheme"
#elseif Apple
configFileName = "AppleScheme"
#endif
// let targetName = Bundle.main.infoDictionary?["TargetName"] as! String
if let url = Bundle.main.url(forResource: "\(configFileName)", withExtension: "plist"),
let dict = NSDictionary(contentsOf: url) as? [String:Any] {
return dict
}
return nil
}
It's working perfectly, but the problem is i don't want to check that #if condition
Can i get that Swift Compiler - Custome Flags value at run time?
Like this let targetName = Bundle.main.infoDictionary?["TargetName"] as! String ?
What exaclty i want is remove #if condition to check scheme.
private func getConfigFile() -> [String: Any]? {
var configFileName: String = ""
let schemename = //Code to get scheme name
if let url = Bundle.main.url(forResource: "\(schemename)Scheme", withExtension: "plist"),
let dict = NSDictionary(contentsOf: url) as? [String:Any] {
return dict
}
return nil
}


