Is there any way to automate scheme configuration for xcode projects generated by SPM?

I've got a project which is using Swift Package Manager which I am working on in XCode. It requires some environment variables to be set at runtime, and currently it's a bit tedious to work with since I have to manually edit the scheme to supply these values every time I regenerate the project.

Is there any way to easily automate this? For instance is this possible with xcconfig files or something similar?

1 Like

Cocoapods does this. It builds a project file and edits an existing project file. I'm not knowledgeable about the details but a little googling leads to a ruby gem called Xcodeproj that appears to do the work.

I've used xcodeproj to do something like this. In particular my use case was adding resources to the generated project. It's worked well for that. It looks like xcodeproj does indeed support configuring environment variables as well:

In case it's helpful, here's the ruby script I use and here is how I integrated this into my workflow via Makefile.

Terms of Service

Privacy Policy

Cookie Policy