Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I add .swiftpm to gitignore?

A .swiftpm directory is created when editing a Swift Package in Xcode. Should I ignore this directory by adding to my .gitignore?

like image 944
Richard Venable Avatar asked Jan 16 '21 20:01

Richard Venable


People also ask

What is .swiftpm folder?

It contains . SWIFT source code files and other project resources. Developers create SWIFTPM files using Apple Swift Playgrounds for iPad and Apple Xcode. If you have Swift Playgrounds or Xcode installed, SWIFTPM files appear as macOS packages. Otherwise, they appear as directories.

Should I commit package resolved swift?

When adding a package in a project, a new swiftpm folder is created under xcshareddata , this should be committed as it contains the resolved versions of our dependencies (stored in Package. resolved file). A Package. swift file indicates that this folder is a package.

What is package resolved file?

swift package resolve. | The swift package resolve command resolves the dependencies, taking into account the current version restrictions in the Package. swift manifest and Package. resolved resolved versions file, and issuing an error if the graph cannot be resolved.

Where is the package resolved file?

The Package. resolved file is inside your . xcodeproj directory at [appName].


1 Answers

According to this post in the Swift forums, the .swiftpm directory "is intended as a place for tools that operate on packages to store state or configuration files of their own that users are not expected to edit directly as source" - it is not exclusive to Xcode support. So to add it to .gitignore could potentially have a bigger impact than just ignoring Xcode files.

You could consider ignoring .swiftpm/xcode instead, but thats also not universally recommended, because Xcode stores shared schemes there, as was mentioned in this rejected pull request.

By default, Swift Package Manager adds xcuserdata/ to the .gitignore, which is the primary ignore you need for using SPM with Xcode.

like image 178
Richard Venable Avatar answered Sep 21 '22 14:09

Richard Venable