How can I pass Xcode Cloud environment variables to Xcode project when building the project using Xcode Cloud?

I am tasked with passing environment variables from the Xcode Cloud server to the Xcode project while building it with Xcode Cloud. When I build the app locally, I fetch environment variables from the scheme.

Then in the codebase, this is how environment variables are accessed:

ProcessInfo.processInfo.environment["MicrosoftCognitiveServicesSpeechKey"]

This is where the environment variables are set in the Xcode Cloud. I right-clicked on the workflow in the Cloud tab found in the Report Navigator of the Xcode and selected "Edit Workflow":

I don't know how to write a code so that when the Xcode project is built using the Xcode Cloud, environment variables can be injected and used.

I have the same issue

@zhouxinxin Did you find a solution to this? I am also facing same issue. Trying to prevent API keys to be exposed from both code and binary is a headache.

Having the same problem, annoying that there I cannot find a solution

How can I pass Xcode Cloud environment variables to Xcode project when building the project using Xcode Cloud?
 
 
Q