Xcode cloud - access to environmental variables inside a test's code

I run my tests on xcode cloud and I want to change different configurations when the tests run on the cloud as opposed to when the run locally. I thought environmental variables should be the way, but I'm not sure how to access them. I tried:

ProcessInfo.processInfo.environment["CI"]

But didn't get any result. Any ideas how can it be done?

Post not yet marked as solved Up vote post of noamohana Down vote post of noamohana
1.3k views
Add a Comment

Replies

I was able to get it to work by doing two things.

  1. Forward the environment variables in your scheme

  1. Copy the Xcode Cloud variables to the environment in ci_pre_xcodebuild.sh

Perhaps if I use $($CI) in the scheme you don't need step #2, but I haven't tested it.

  • Thank you for sharing this 👨‍💻

Add a Comment