Why Bitcode increases the size of an iOS SDK?

And why does it not matter…

Sowndharya Maheswaran
2 min readJan 23, 2021

First of all, what is this Bitcode?

I am assuming you are an iOS developer. So, let’s dive straight in. According to the Apple docs, Bitcode is an Intermediate representation of a compiled binary. If that makes no sense at all, you’re not alone friend. If not, I revere you (friend?!).

Now about the Intermediate representation of a compiled binary — Let’s take a step back. What is the first thing you do to upload an App to the App Store? Before anything else you archive your app into an xcarchive file. During this process, the Xcode compiler, known to many as the LLVM compiler, will convert your source code into machine code.

Here’s something you should know. LLVM does this conversion in a series of steps. One such step is to produce an Intermediate Representation of the source code— which can later be optimised in subsequent steps. Apple took advantage of this process. They wanted to optimise our code further before deploying it into your mobile phones. They introduced Bitcode.

Bitcode is the machine code in this intermediate state, waiting to be optimised. Now, instead of LLVM optimising this further, we App devs would upload Bitcode to App Store, so that Apple can execute this process on its own.

Why is Bitcode useful?

As limited as it may sound, this comes in handy to Apple when they want to achieve changes in their architectures and don’t want to wait until the App developer supports that architecture. This is evident with the new Apple Silicon introduction. But keep in mind that this is helpful to even the minor changes in existing architectures.

Back to the main topic — Why is there an increase in size?

I am an iOS framework developer and the size of the framework is quite a concern since it directly contributes to the size of the Apps. When enabling Bitcode, the size of the SDK increases dramatically!!!

And why is it so? It’s because Bitcode does not replace the final machine code. It is in addition to the final machine code. So, if you are building your framework for two targets — arm7 and arm64 then there are two more binaries added to the framework. Although it is still a black box why the Bitcode binary is so much larger than the actual binary.

The second main topic — Why does this size increase not matter?

It’s because Bitcode only stays in Apple’s servers. When an App is being deployed into the phone Bitcode is not included in the final App. It is purely used by Apple for optimising code while it is still in the server. Simple as that.

Tidbit:

  • Bitcode is not created for the simulator architectures.

There is a similar concept about dSYM and framework sizes. There will be a second part on this blog. Stay Tuned!

--

--