In Objective-C we could add a C Flag of -DVAR_NAME=@\"string value\"
and then get the value with NSString *var = VAR_NAME
.
How do we do this in Swift?
An example of this would be defining an api host based on the current git branch. Say the branch is feature1
and it should connected to https://feature1.example.com
. A shell script can easily find the current branch and add the C Flag. Then in Objective-C we can use the branch from the shell script to generate the api host url.
Update
I am not asking about boolean flags. I need to pass a string value.
Update 2
So far all I can come up with is to use a build script to generate a swift class.
Update 3
Another option is to add custom keys to the Info.plist. This isn't always an acceptable solution but for configuration values this works.