When setting up a bot there's an "Environment" tab that looks like this:

I would expect to be able to access this Environment variable in my test like this:
NSString *username = [[NSProcessInfo processInfo] environment][@"accountEmail"];
But that comes back as nil. And I can verify that [NSProcessInfo processInfo] is populated with other data by logging its contents to the console.
I think this is a pretty new Bot feature (neither the 2015 WWDC videos nor Apple's documentation even mention this tab), but has anybody had success accessing these bot environment variables?
In order to access an environment variable set through a bot's "Arguments" tab, you must first account for that variable in your scheme.
In Xcode 9.2, go to Edit scheme... > Run > Arguments > Environment Variables and add your environment variable with Name accountEmail and Value $(accountEmail). Then the value you set for the environment variable in your bot's configuration should be accessible in code through (in Swift 4) ProcessInfo.processInfo.environment["accountEmail"].
I'm noticing the same thing. Seems like a bug in Xcode Server. You should probably log a Radar.
In the meantime, you can add environment variables to schemes. You can make several schemes for different configurations and switch which one your Bot uses. It's not ideal, but it gets the job done.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With