Adding and Removing Swift Package dependencies in Xcode
Table of Contents
Apple introduced Swift Package Manager (SPM) in 2017 as a way to manage dependencies in Swift. Then two years later (Xcode 11), SPM has fully integrated into Xcode. We can easily manage Swift Package dependencies since then.
In this article, I will show you how easy it is to manage Swift Package dependencies in Xcode.
- Adding a Package dependency to your app.
- Updating a Package dependency.
- Removing a Package dependency.
Adding a Package dependency
To add a package dependency to your Xcode project.
- Select File > Add Packages...
- Enter a repository URL of a package you want to add in the search field on the top right. In this example, I try to add Swift Algorithms package, and this is the URL I use https://github.com/apple/swift-algorithms.git.
- Select a version you want to add to the Dependency Rule.
- Then, click the "Add Package" button to add.
You can also add a package dependency from your target's General pane.
- Click on the target that you want to add a package.
- Select the General pane.
- Scroll down to the "Frameworks, Libraries, and Embedded Content" section.
- Click the + button, select "Add Other...", and choose "Add Package Dependency...".
You can easily support sarunw.com by checking out this sponsor.
AI Grammar: Correct grammar, spell check, check punctuation, and parphrase.
Updating a Package dependency
To update an individual package.
- Find a package you want to update in the Project Navigator. All packages sit at the bottom of the panel under the "Package Dependencies" section, so you need to scroll down a bit.
- Right-click on the package and choose "Update Package" action.
To update all packages.
- Right-click on the Package Dependencies section header.
- Choose "Update to Latest Package Versions".
Or Select File > Packages > Update to Latest Package Versions.
You can easily support sarunw.com by checking out this sponsor.
AI Grammar: Correct grammar, spell check, check punctuation, and parphrase.
Removing a Package dependency
If you no longer need any package, you can remove it using these steps.
- Click on the project root file.
- Select the "Package Dependencies" pane.
- Select the Swift package you want to delete from the list.
- Click the minus (-) button to remove the selected package.
Read more article about Xcode, Swift Package, or see all available topic
Enjoy the read?
If you enjoy this article, you can subscribe to the weekly newsletter.
Every Friday, you'll get a quick recap of all articles and tips posted on this site. No strings attached. Unsubscribe anytime.
Feel free to follow me on Twitter and ask your questions related to this post. Thanks for reading and see you next time.
If you enjoy my writing, please check out my Patreon https://www.patreon.com/sarunw and become my supporter. Sharing the article is also greatly appreciated.
Become a patron Buy me a coffee Tweet ShareEasy way to Format Date in SwiftUI Text
Since iOS 14, SwiftUI Text has had many initializers dedicated to presenting dates. Let's explore all of them.