Secret Environment Variables with Xcode Cloud

I see from the WWDC video that it's possible to use secrets, like an API_KEY variable, when running Xcode Cloud builds.

How are these variables accessed from code? Is it something like this?

ProcessInfo.processInfo.environment["API_KEY"]

If so, how are we supposed to run the tests locally? Is the idea that every developer creates their own non-shared schemes and adds all secret environment variables to that scheme?

I had the same question and tried it out. Using ProcessInfo.processInfo.environment to access Xcode Cloud Environment Variable Secrets like I'm used to with Environment Variables defined in Xcode Schemas did not work for me. the docs don't go into much detail on the Xcode Cloud Environment Variables but reference that they can be used in custom build scripts: https://developer.apple.com/documentation/xcode/xcode-cloud-workflow-reference#Custom-environment-variables

Secret Environment Variables with Xcode Cloud
 
 
Q