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["API_KEY"]
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.
There was not much that I could have tried because I am new at DevOp stuff and resources regarding this topic was so limited.