Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

swift
xcode
apple
github
communitycreator

How to install 3rd party dependencies using SPM

Amey Sunu

Swift Package Manager (SPM) is a built-in Xcode package installer similar to CocoaPods and Carthage, except SPM is made by Apple.

How to use SPM

It’s really easy to use SPM. To get started, simply open up your Xcode project and click Add Packages. In this section, you can find Swift packages created by Apple, as well as your personal Github projects.

If you are used to CocoaPods, then you know that all packages have a Git repository, which is what we need to get. So, simply grab the Git URL for the package you’d like to install and then paste it.

In the screenshot above, I use Alamofire which is an elegant HTTP manager for Swift.

Now, just add the package and you’re done!

This is much easier than CocoaPods or Carthage and is really seamless when it comes to cloning a project from open source and using it directly.

Advantages

Unlike CocoaPods, there is no creation of additional files like the Podfile or a .xcworkspace file that is usually created after the Podfile.

SPM automatically downloads the required packages from open-source, whereas in CocoaPods users have to manually install the pods. This is a huge time saver that I’ve personally found very useful.

RELATED TAGS

swift
xcode
apple
github
communitycreator
RELATED COURSES

View all Courses

Keep Exploring