I want to use global variables for defining the API base path of my app based on the current building configurations (dev, production). These are the current approaches:
1)
struct ApiSettings {
static let API_DEV_BASEPATH = "http://dev.myapp.com"
static let API_PRODUCTION_BASEPATH = "http://prod.myapp.com"
// Return the basepath for the current app runtime mode
static var API_BASEPATH:String {
var bPath: String!
#if DEBUG
bPath = API_DEV_BASEPATH
#else
bPath = API_PRODUCTION_BASEPATH
#endif
return bPath
}
}
2) (Here I define a staging environment too)
#if DEBUG
let API_BASEPATH = "http://dev.app.com"
#elseif STAGING
let API_BASEPATH = "http://staging.app.com"
#elseif RELEASE
let API_BASEPATH = "http://production.app.com"
#endif
but when I try to use API_BASEPATH in my app the compiler complains about an "Unresolved Identifier"
I'm not sure which the most elegant solutions to be adopted. PS. I'm using Swift3
plistfiles.