I've got five different schemes: Debug, Release, Staging, Production, Testing. I've already set them all up.
I want to change the text of a label and the background color of a view according to the specified schemes.
In AppDelegate
I've implemented the following method:
func setDomainEnv() {
#if Debug
serverEndPointURL = "www.debug.com"
var fancyBackgroundColor = UIColor(hue: 0.007, saturation: 0.589, brightness: 0.572, alpha: 1.0)
#elseif Testing
serverEndPointURL = "www.testing.com"
var fancyBackgroundColor = UIColor(hue:0.971, saturation:0.715, brightness:1, alpha:1)
#elseif Staging
serverEndPointURL = "www.staging.com"
var fancyBackgroundColor = UIColor(hue: 0.373, saturation: 0.602, brightness: 0.863, alpha: 1.0)
#elseif Release
serverEndPointURL = "www.release.com"
var fancyBackgroundColor = UIColor(hue: 0.571, saturation: 1.0, brightness: 1.0, alpha: 1.0)
#elseif Production
serverEndPointURL = "www.production.com"
var fancyBackgroundColor = UIColor(hue: 0.66, saturation: 0.516, brightness: 0.871, alpha: 1.0)
#endif
}
The method gets called in the application didFinishLaunchingWithOptions
method:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
self.setDomainEnv()
return true
}
I've also set up a file called Constants
which stores my variables:
import Foundation
import UIKit
var serverEndPointURL = "www.apple.com"
var fancyBackgroundColor = UIColor.black
In my ViewController
, I use those variables in my viewDidLoad
method:
override func viewDidLoad() {
super.viewDidLoad()
label.text = serverEndPointURL
self.view.backgroundColor = fancyBackgroundColor
}
However, the only thing that changes is the text of the label. The background color does not change based on the specified scheme. It is always black (the value stored in the Constants
file). it will not change based on the selected scheme. Any ideas?