-
Notifications
You must be signed in to change notification settings - Fork 29
Description
We love that this SDK now supports installation via Swift Package Manager, and there's an opportunity to make it install much faster.
SPM clones this entire repo when resolving packages, and since the xcframeworks are stored in the repo, all versions get downloaded. During local development, this isn't a big deal because Xcode does a pretty good job of maintaining a cache so you're not cloning from scratch every time. But on a build server, it's easy to get into a situation where you're having to clone this entire repo on every run. In our case, we're seeing it add 70s to our total build duration.
Fortunately, there's an alternative: set up a repo that only contains the package manifest and have it point to a pre-built xcframework hosted elsewhere.
Lottie is a good example of a setup like this. Their readme puts it nicely:
When using Swift Package Manager we recommend using the lottie-spm repo instead of the main lottie-ios repo. The main git repository for lottie-ios is somewhat large (300+ MB), and Swift Package Manager always downloads the full repository with all git history. The lottie-spm repo is much smaller (less than 500kb), so can be downloaded much more quickly.
Instead of downloading the full git history of Lottie and building it from source, the lottie-spm repo just contains a pointer to the precompiled XCFramework included in the latest lottie-ios release (typically ~8MB). If you prefer to include Lottie source directly your project, you can directly depend on the main lottie-ios repo by referencing https://github.com/airbnb/lottie-ios.git instead.
Here's a link to their package manifest: https://github.com/airbnb/lottie-spm/blob/90fa25ba0feb39c22915d41b55226cc95955dfcc/Package.swift
Note the need for a stub non-binary target. Their solution works well and is similar to the approach taken with other pre-compiled swift packages (e.g. https://github.com/mapbox/mapbox-core-maps-ios)