Swift package update-xcodeproj?

Hi all,

First forum post so please go easy if there's an obvious answer here! :roll_eyes: I'm currently about a week into building a first Server Side Swift app and have split out a lot of Swift code from an iOS app into reusable modules for Client / Server usage (across macOS + Linux) and so far the experience has been :raised_hands:

However, now the code is split out and the server app is in active dev using Xcode one issue I've come across using the SPM is the following:

  1. For Linux testing I'm using docker-compose + docker secrets etc. passing in config using ENV variables.
  2. For macOS testing I'm using Xcode and passing in config using Edit Scheme -> ENV variables

Xcode works great until I need to add a new package dependency and have to run:

  1. swift package update
  2. swift package generate-xcodeproj

and lose all the Scheme ENV variables. Is there a way to easily update dependency related info in the Xcode project file without losing other settings (such as Scheme settings + ENV variables)? e.g. swift package update-xcodeproj instead of swift package generate-xcodeproj?

Thanks in advance,


Something I've done with the CMake-generated Xcode project for the Swift compiler itself is to make a separate workspace and put the generate project inside that. That way I can keep schemes in the workspace while not worrying about having to maybe regenerate the project from scratch sometimes. I think this is still a reasonable request for the package manager, though.


Unrelated: Wow, I never thought of this and will adopt it immediately.

Thanks for the quick response - sounds like the perfect workaround.

I've also raised an improvement suggestion SR-10132 for a new command "swift package update-xcodeproj".

I use the same approach as @jrose, works pretty well. Thanks for filing the JIRA!

That’s also useful to use packages in playgrounds ;)