Added in Swift 5.5, package collections are a way to group and search Swift packages. You can add collections into Xcode 13, giving you a much easier way to add your favourite or commonly used packages into your apps.
The Swift Package Index dynamically generates package collections containing all packages from every package author in the index. Each author page includes a "Copy Package Collection URL" button that copies a link you can directly paste into Xcode. For example, from the Vapor project's author page on the Swift Package Index:
Using Package Collections with Xcode 13
Select your project in the Xcode project navigator, select it again in the projects and targets list, and switch to the Swift Packages tab:
+ button below the Packages list, and you'll see a Collections list on the left and details about the packages in each collection on the right.
+ at the bottom of the Collections list and paste in the URL to a package collection. That's it! You can now add packages from that collection to your project by selecting one and clicking "Add Package".
Note: When adding a package collection from the Swift Package Index, you'll see a warning "Package Collection Not Signed". We're working on adding support for signed collections.
Using Package Collections with the Swift Package Manager
To add a package collection using the
swift command-line tool, use the
swift package-collection add command:
swift package-collection add https://swiftpackageindex.com/vapor/collection.json
Note: If you see an error
unable to invoke subcommandwhen running
swift package-collection, ensure you have at least Swift 5.5 installed. You can check which version of Swift you're running with
Then, to describe a package, use the
swift package-collection describe command:
swift package-collection describe https://github.com/vapor/vapor
The default output is plain text, but the command can output JSON if you add the
--json parameter to the
Finally, to remove a package collection, call
swift package-collection remove:
swift package-collection remove https://swiftpackageindex.com/vapor/collection.json
For more information about package collections, see the documentation.