Swift Package Manager (SPM) is a built-in Xcode package installer similar to CocoaPods and Carthage, except SPM is made by Apple.
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.
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.