DEV Community

himaratsu
himaratsu

Posted on

3 1

Use Carthage effectively

Carthage

Carthage is one of the most popular dependency management tool for iOS.

In my article, I introduce several convenient command to save your time.

Command

carthage update —platform ios

When executing carthage update, carthage create Cartfile.resolved from Cartfile you prepared. Then,
build frameworks.

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.

carthage bootstrap —platform ios —cache-builds

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.

Specify libraries

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.

Use latest version of OSS

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.

Recap

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.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay