SPM .gitignore excludes Xcode projects

Jan 2, 2020 · Follow on Twitter and Mastodon spmxcode

When you create Swift Packages with swift package init, the default .gitignore excludes Xcode projects. This will cause problems if you later add an Xcode project to the package.

SPM doesn’t require an Xcode project. You can just place source files in Sources and test files in Tests and SPM will happily consider it to be a package.

If you want to add a demo app, Carthage support etc. you however need an Xcode project. Still, the default SPM generated .gitignore file looks like this:


This means that your demo app will be excluded, if you don’t remove /*.xcodeproj from .gitignore before commiting your changes.

This happened to me when I published a new package. It took me a while to realize why people claimed they couldn’t find the demo app…which I believe did cost me some stars.

To avoid this problem, use a better .gitignore template, or at least remove /*.xcodeproj before you add a project to the package.

Discussions & More

Please share any ideas, feedback or comments you may have in the Disqus section below, or by replying on Twitter or Mastodon.

If you found this text interesting, make sure to follow me on Twitter and Mastodon for more content like this, and to be notified when new content is published.

If you like & want to support my work, please consider sponsoring me on GitHub Sponsors.