Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add a package collection to my Xcode project?

In Xcode 12.5 with iOS deployment target 14.5 I want to import the swift-collections library to use module OrderedDictionary.

When I add the following URL https://developer.apple.com/swift/packages/collections/apple.json as a package repository I get the following error:

enter image description here

I assume this is an authorisation issue. Where should I enter my credentials?

like image 275
Javide Avatar asked Sep 21 '25 10:09

Javide


1 Answers

Swift 5.5 and Xcode 13+

Package Collections is introduce in Swift 5.5 with Xcode 13.

From Swift.org

You can add it using the new package-collection add option from the SwiftPM command line

$ swift package-collection add https://developer.apple.com/swift/packages/collections/apple.json

After firing the above command, select your project in the Xcode project navigator, select it again in the projects and targets list, and switch to the Swift Packages tab and click the + button below the Packages list, and you'll see a collections list. And add swift-collections package from the list.

enter image description here

Note: Ensure you have at least Swift 5.5 installed. You can check which version of Swift you're running with swift --version.

Below Xcode 13

Valid URL is: https://github.com/apple/swift-collections

You have to add swift collections package instead of json.

Check Using Swift Collections in your project section from here

After installing you will get the following tab for selection target. And select OrderedCollections target.

Documentation : https://github.com/apple/swift-collections/blob/main/Documentation/OrderedDictionary.md

enter image description here

like image 88
Raja Kishan Avatar answered Sep 23 '25 02:09

Raja Kishan