Building static frameworks under Carthage

Mark Jarecki
fluxom
Published in
4 min readJul 16, 2019

--

Make your favourite Carthage frameworks static

Introduction

After expounding the benefits of static frameworks for inclusion in your next iOS et al. app, I’ve had a few of you ask me:

How do you build third-party static frameworks under a dependency manager, like Carthage?

Carthage supports building static frameworks, as described in its documentation. However, the script detailed in that example is dated, because since Xcode 9 beta 4, Xcode natively supports static libraries with Swift sources. Making the xcconfig LD hack no longer necessary.

I’ve written a BASH script to simplify the process of building static frameworks with Carthage. I’ll detail what it does and how to use it.

The Problem

The frameworks built by Carthage are dynamic by default.

It is necessary to override some xcconfig properties with a temporary file to make static frameworks build successfully.

Mach-O type

staticlib

The MACH_O_TYPE determines what is being built — executable, dynamic library, static library, bundle, or relocatable object file. As we are building…

--

--

Mark Jarecki
fluxom
Editor for

Interactive product developer and information visualisation aficionado