This is a wrapper around Carthage CLI that helps you to build specific versions of your dependencies only once and then reuse the built binaries.
Version of Xcode used to build binaries is taken into account.
CarthageWrapper also provides a way to download binary-only dependencies without using Carthage CLI at all. Carthage itself is not that flexible when you need to download a binary-only dependency. Furthermore this is not possible at all if you have some specific kind of authentication on the backend side.
Fat binaries are sliced into xcframeworks. This way you get meaningful build errors when one of your dependencies doesn't support target architecture or platform.
Using Mint:
$ mint install swiftlane-code/CarthageWrapperUsing the Swift Package Manager:
$ git clone https://github.com/swiftlane-code/CarthageWrapper.git
$ cd CarthageWrapper
$ swift build -c release
$ cp -f .build/release/CarthageWrapper /usr/local/bin/Built binaries are stored in form of zipped xcframeworks in a remote storage.
For now GitLab Packages is the only supported remote storage (zips are uploaded as Generic Packages).
Projects which produce multiple xcframeworks are zipped into single .zip archive.
CarthageWrapper also caches zip archives with prebuilt binaries locally to prevent excessive downloads. This is extremely handful when you need to frequently switch between branches of your project which have different dependencies version.
Built dependencies are versioned in the following format:
<version of dependency>_<swift version>_<builder version>
Where:
<version of dependency>- version or commit SHA of the dependency repo.<swift version>- version of swift tools which were used to build the dependency. This is parsed from$ swift --versionoutput.<builder version>- version of logic used to resolve versions of built binaries. This is defined aslet wrapperVersion: String = "2"in BootstrapCommandRunner.swift.
Let's say this is your Cartfile.resolved:
github "MakeAWishFoundation/SwiftyMocky" "4.2.0"
Then CarthageWrapper will pack SwiftyMocky.xcframework into a zip file named SwiftyMocky@4.2.0_swift-5.6.1_builder-2.zip.
All binary-only dependencies should be listed in CartfileBinary.yml and not in Cartfile.
Downloading of binary-only dependencies is done without any help of Carthage CLI.
So that you have to list only the dependencies which you are willing to build from source in your Cartfile and Cartfile.resolved.
- Execute
$ carthage bootstrap --no-build. - Parse
Cartfile.resolvedandCartfileBinary.yml - Try to download prebuilt binaries of required dependencies from (2):
- prebuilt binaries are either downloaded from url
specified in
CartfileBinary.ymlor from the remote storage.
- prebuilt binaries are either downloaded from url
specified in
- If downloading of a prebuilt binary failed:
- Execute
$ carthage build ... --use-xcframeworksto build it. - Upload built binaries to the remote storage.
- Execute
- Slice fat binaries in
Carthage/Build/iOSand create respective xcframeworks inCarthage/Build.
Correct state of Carhage/Build folder is guaranteed by use of *.smversion files which are placed alongside the binaries. These files are used to track versions of dependencies which are currently ready-to-use.