Carthage is one of the most popular dependency management tool for iOS.
In my article, I introduce several convenient command to save your time.
When executing carthage update, carthage create Cartfile.resolved from Cartfile you prepared. Then,
In this command, you should specify platform you want to use frameworks in.
carthage update —platform ios
Carthage usually create multiple platforms frameworks(iOS, watchOS, tvOS, and macOS), but maybe not use these all.
When executing carthage bootstrap, carthage build frameworks from Cartfile.resolved file. Not from Cartfile.
carthage bootstrap —-platform iOS —cache-builds
—cache-builds means not rebuilding frameworks if you already had built frameworks in Carthage/Checkouts/
Fortunely, carthage automatically check if framework is built in same Swift version. If not, rebuild it.
Cartfile is share between multi platforms. For example, iOS and watchOS.
Basically, command is here:
carthage bootstrap —platform iOS,watchOS
But it has problem. In many cases, watchOS doesn’t use all dependencies defined in Cartfile.
So, my recommend is:
carthage bootstrap —platform iOS
carthage bootstrap —platform watchos SWXMLHash
Separate command, and pass library name to build command for watchOS.
To shorten build time, you can use framework binary. It’s provided by Library Author, so you can use implicitly.
To use it, your project swift version needs to be same as swift version of that binary. If you use Swift 4.2, using library of version build in Swift 4.2.
Carthage skip checkout and build steps, so it is very efficiently.
Carthage is great tool, but build time is bottleneck. I introduce tips to resolve it.
Make hope this article helps you!
*I'm studying English. If you notice English mistake, please tell me in the comments.