Xcode seems to forget Schemes when using SPM

I've been building a project using SPM to define all the modules within the app. When I update the Package.swift file Xcode generates the new Schemes for me automatically. The project set up is very similar to the Isowords project from PointFree... GitHub - pointfreeco/isowords: Open source game built in SwiftUI and the Composable Architecture.

But then after some time something will happen and it will "forget" a scheme. It's not in the list of schemes and when I "Manage schemes" it isn't there either. When I tap "Autocreate Schemes Now" nothing happens.

I've tried various things to fix it. Resetting package caches, updating the package.swift file, cleaning the build folder, deleting derived data, none of that seems to have fixed it.

In git there are no changes to suggest that anything has changed. The only way I have found to consistently fix it is to re-clone the project into a new directory. Then Xcode generates the schemes and my missing scheme is back. All the other schemes are there.

Does anyone know:

  1. Why this happens?
  2. How to fix it once it happens?

I'd like to avoid manually adding the scheme as that puts the responsibility on us to create it correctly and keep track of it. I'd just like Xcode to keep managing them and not suffer from amnesia. :smile:

Thanks

I have feeling that the schemes that are going missing were in the .swiftpm directory in the root of your package before Xcode assassinated them (they were probably ignored by your gitignore which would be why you saw no git changes). To fix the issue, deleting the .swiftpm folder and then restarting Xcode should be sufficient.

Just a little plug for a relevant project of mine, but if you want to make an app using just a Swift package (which it seems is kind of what Isowords is trying to so) you can check out Swift Bundler. The public version only supports macOS but Ill release iOS support later this year when I have more time to work on it and polish it off (it’s currently under early access).

2 Likes

Wow, thanks very much. I'll give that a try and report back. Also, I'll check out SwiftBundler too.

Thanks

1 Like

That worked! So much easier than I expected it to be.

Thanks

1 Like

You’re welcome, I’m glad it worked! Cause I had no more ideas :)