Is Swift Package Manager production ready?
In other words, is it time to migrate from Carthage, CocoaPods, or maybe GIT Submodules?
A few months ago we migrated all our dependencies to make use of Swift Package Manager (SPM). We used to use GIT Submodules and never migrated to something like CocoaPods because we knew we were migrating to SPM soon, either way. It was support for resources in packages that made us decide to start the migration.
Today, we're linking around 16 local packages and several external packages through SPM. Even though it's not always great yet, we're super happy that we decided to migrate and we would definitely recommend using SPM for new projects today.
Reasons for using SPM
SPM is integrated into Xcode which is a hard to beat advantage over frameworks like CocoaPods. Its support is going to improve in the upcoming years, even this upcoming WWDC will likely bring a lot of improvements.
The fact that Swift 5.4 came with a lot of improvements proves that Apple puts serious efforts into improving SPM. You can read more about this in one of the articles I linked in this week's edition.
Today's downsides of SPM
There are still a few downsides of SPM today. It's not easy to use libraries like SwiftLint when editing single packages, which can be a downside for keeping your code quality up.
Code coverage is currently not working on Apple Silicon Macs and a few small issues can sometimes be frustrating:
- File headers are not automatically updated (It shows File.swift instead of the filename, for example)
- Creating a new file using the Unit Test template creates an Objective-C class (why?!)
These are just a few observations, but not enough for me to discourage using SPM. In the end, I feel like these issues will be solved sooner than later. Using SPM today prepares you for the future.
Would I recommend migrating today if your using CocoaPods? Maybe not yet. Maybe wait till WWDC is there and more improvements arrive. CocoaPods has quite a few nice features that aren't supported by SPM today and I can totally imagine those features make it hard to move away today.
Feel free to reach out to me on
Twitter and share your opinion.
Enjoy this week's SwiftLee Weekly!