Announcing the pod merge plugin for Cocoapods!

Improve your app's startup time by reducing dynamic frameworks

If your app uses a lot of cocoapods with the use_frameworks directive in your Podfile, it’s startup time (especially dylib loading time during pre-main) can get significantly high. The use_frameworks directive links your pods as dynamic frameworks, and they are then loaded one by during your app’s startup, slowing it down considerably.

If you’ve watched Apple’s 2016 WWDC talk Optimizing App Startup Time, Apple recommends you to merge your dynamic frameworks to improve your app’s load time.

I’m delighted to announce a cocoapods plugin to do just that! Introducing cocoapods-pod-merge!


Pod-Merge-Logo

🗄 Merges your pods based on a MergeFile

The plugin introduces a new file to your workflow, the MergeFile:

MergeFile

You define groups of pods you want to merge, and add pods to group just like you would to a Podfile. Pods inside the group are merged automatically when you run pod install!

📝 Can merge both Swift & Objective-C Pods

The plugin can merge both Objective-C and Swift Pods. Mixing them in the same group however is not recommended, due to special settings required for Swift pods.

🚀 Can merge pods that are dependant on each other, even fixing imports!

Add the has_dependencies! flag to a group, and the plugin takes care of merging pods that are dependant on each other.

PodFile

It even fixes imports inside the merged pods, since the pods are now part of the same framework!

𝍇 Minimal changes to your Podfile

PodFile

You only need to add one line to your Podfile to start using the plugin, and use the merged pods instead of the individual ones!

፨ Keeps logical separation between merged pods using C modulemaps

After merging the pods, the plugin automatically creates a C modulemap for the resulting framework, helping you still import the merged pods individually!

PodFile

Yay for no import pollution! (except Swift pods)

🗳 Share code between your app and extensions, without duplicate symbols

Share these merged dynamic frameworks between your app’s main binary and extensions, without creating multiple copies of the merged cocoapods within them (unlike static linking).

✅ It’s open-source!

Cocoapods-pod-merge is open source, and we’re excited to get your feedback on the plugin and supporting more use cases in the future!

Checkout the step by step getting started guide in project readme, the performance improvements you can expect, and important tips and tricks on how to start grouping and merging pods used by your app. You can even find out how the plugin works if your’re curious!

There’s an example project as well to see the plugin in action!

The plugin is designed to be integrated right into your existing pod install workflow, so that everything works as it is.

Here’s to faster apps! 🍻

Swiftier