In my main target
.plist file I have this:
I'm using a build schema per each environment I have (development, staging, production), so I set
MY_BASE_URL in Environment Variables in the build step of the schema.
Then in code I have this:
NSString *baseURL = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"HIHomePage"];
That turns out to be an empty string, however stuff such as
CFBundleName is being picked up.
What am I missing here?
To get values from environment variables use the following code
NSString *baseURL = [[[NSProcessInfo processInfo] environment] objectForKey:@"MY_BASE_URL"];
Ref : http://rosettacode.org/wiki/Environment_variables#Objective-C
To add items in plist from scheme, you should dd a user defined build settings with name
MY_BASE_URL and enter values as per your scheme. Then use it in
For adding user defined build settings, Select target From Editor menu > Add Settings > User defined Settings