WWDC23: Meet mergeable libraries
Mergeable libraries are a new feature in Swift that allow you to merge multiple libraries into a single binary. This can improve the performance of your app by reducing the number of files that need to be loaded at runtime. In addition, mergeable libraries are also smaller than individual libraries, which can save space on disk and in memory.
New library type: Mergeable library
If you’ve written multi-architecture code or open source code before, you know that Apple had two types of libraries, static and dynamic. We now have 3 library types along with the combinable library type. As much as possible, the new library type is focused on solving the problems of static and dynamic libraries. While solving these problems and disadvantages, it promises many advantages and also solves the complexity of multiple architectures. Let’s examine together what this library, which Apple introduced at this year’s WWDC23, provides us.

Advantages
Mergeable library brings together the static or dynamic libraries you have created before and presents them to you under a single roof. In doing so, it does not cost you extra. Here are some advantages of the mergeable library;
- Mergeable libraries can reduce the size of your apps by up to %50.
- Mergeable libraries can improve the launch time of your apps by up to %20.
- Mergeable libraries can make your apps more reliable by reducing the number of crashes.
- Mergeable libraries make it easier to manage your dependencies, as you can update them all at once.
- Mergeable libraries can improve the security of your app by reducing the number of potential attack vectors.
Using Mergeable Libraries to Improve Your Apps
To use mergeable libraries, you need to add the MERGED_BINARY_TYPE build setting to your app target and set it to automatic. You also need to add the MERGEABLE_LIBRARY build setting to each library that you want to merge. If you have any problems with mergeable libraries, you can disable them by removing the OTHER_SWIFT_FLAGS flag from your project’s build settings.
Once you have configured your project for mergeable libraries, Xcode will automatically merge all of your direct dependencies into a single binary. This will improve the performance and reduce the size of your app.

Mergeable libraries are a new feature in Swift that can be used to improve the performance, size, and security of your app. If you are looking to improve the performance, size, and security of your Swift app, then you should consider using mergeable libraries.
I hope this article has helped you to understand the benefits of mergeable libraries and how to use them to improve the performance and reliability of your apps. If you are a developer who is interested in improving the performance and reliability of your apps, I encourage you to check out the WWDC 2023 Meet Mergeable Libraries session.




