What is SPM? and how to make & adopt SPM?

ByungwookAn
3 min readJun 3, 2023

--

image source: https://www.swift.org/package-manager/

Intro

Nowadays, there are so many great 3rd party libraries. So Developers can easily adapt features offered by the 3rd party library and improve the performance and stability of their apps. If you’re an iOS developer, You may have adapted 3rd party libraries in your app using Cocoapods, Carthage, and so on.

But recently, The paradigm of libraries has changed fast because of SPM(Swift Package Manager). It is a powerful, stable, and easy way to adapt the library. So Today, I’ll talk about the advantages of SPM and how to make SPM and adopt SPM in your app.

At https://www.swift.org/package-manager/, you can easily read about SPM.

Advantage of SPM

  1. SPM is a 1st party library. It’s an official tool, so it’s a dependency tool that will continue to evolve in the future under Apple.
  2. SPM automatically manages dependencies used in internal modules, and you don’t need to add a pod install like Cocoapods whenever you add or change dependencies.
  3. SPM is designed to be easy to use and integrate. You don’t have to turn on the terminal. You can easily find and adapt the libraries in Xcode.
  4. SPM also works on Linux, enabling cross-platform development.

How to make & adapt SPM

How to make SPM?

  1. Turn on your Xcode. and make a new Swift Package file. (Multiplatform -> Swift Package).

2. Write some code to Test.

3. Create a repository on GitHub. (Must be pre-connected)

4. make a tag and release.

That’all! Isn’t it really simple? and It’s time to adapt your new package in your app.

Adapt SPM in your app

  1. Make a new app file.

2. put the + button in Packages.

3. Copy your package’s git URL and paste it into Xcode.

4. Test your new & simple package works well!

That’s all! From now on, You can make your own packages and adopt packages in your app using SPM without any problems.

Conclusion

SPM is really powerful & simple to make and adapt your apps. I’m pretty sure that SPM will soon overwhelm other third-party libraries. If you read my post and get used to SPM, I will be very proud.

--

--