Whew! That Was A Handful, Eh?
Even though it may seem that this was a comprehensive treatment of the Swift Package Manager, it was really just a fairly basic introduction.
The examples were shallow and linear, and we didn’t even get into writing executable code in the package manifest files.
But we did learn enough to make the Swift Package Manager a useful and productive tool for our development work.
Let’s review where we went:
- In the introduction, I discussed my exploration of four different package manager choices, and what drove my decision to use the SPM.
- We then discussed the three basic ways to create packages:
- We also learned that we can’t name our package “
Package_B
“, and one reason the SPM may default to static libraries. - We learned to create a manifest file, and learned:
- We learned to use swift build to help us debug packages.
- We learned how to add packages to our Xcode projects:
- We learned about the Main Package List, in the Xcode Project Navigator
- We learned that we can simply drag a local package’s project directory into the Xcode Project Navigator, and it will load, exactly like an Xcode project.
- We learned that we can use the File Menu New > submenu to add the package from a git repository.
- We learned that we can add from the “+” button in the General and Build Phases target tabs.
- We learned that we may need to clear the caches, and reload the dependencies.
- We learned how SPM helps us to deal with “dependency hell.”
- We then went through seven examples:
- A Simple, Single-Package, Static Library
- Two Simple, Nested Static Libraries
- Two Simple Nested Libraries, With the Top One Being Dynamic
- Two Simple Static Libraries (but Newer Version)
- Three Layers Of Packages, With Dynamic Frameworks (Has Hardened Runtime Issue)
- Three Layers Of Packages, With A One-Level-Down Dynamic Framework (Has Hardened Runtime Issue)
- Three Layers Of Packages, With All Static Libraries
This was by no means, a complete course on the Swift Package Manager, but it should allow us to move forward with integrating into our workflow as a powerful, intuitive and safe way to mage our dependencies.
Further Reading
- The Swift Package Manager Main Swift Site Documentation Hub
- Apple Developer Documentation Hub for Swift Packages
- Ray Wenderlich Course on Swift Packages
- Swift By Sundell Article on Swift Packages
- Another Sundell Article on Swift’s Xcode Integration
- A Somewhat “Dated” Twillio Article on Swift Package Manager
Frankly, there’s not a lot of exhaustive resources out there. The SPM was a “server-only” toolkit for many years, so it’s just starting to see a lot of use with its Xcode integration.
Expect to see a great many high-quality, up-to-date explorations of it, soon.