Skip to main content

Extract sub-libraries from a given iOS/Swift library without access to source code to avoid namespace clashes using lipo and ar command

We at WeltN24 were facing the problem that two libraries that we integrated in our iOS project, used the same sub-library which resulted in naming conflicts due to the non-existing namespaces in Swift.

If you know what you are doing you can try to solve this conflict by extracting the shared sub-library from one of the libraries you want to integrate. You can even do this if you don't have access to the source code using the lipo (create or operate on universal files) and ar (create and maintain library archives) commands.

Why you should know what you are doing?
Manipulating unknown archives can result in unforseen effects because of the fact that you don't know anything about how the provider of the archive uses the sub-library, which version of the library was used or if the source code of the library was manipulated. So...
You should know what you are doing manipulting archives :)

The script is processing the files in following order:

  1. Extracting architecture slices of multi-architecture file $src_lib
  2. Excluding library archives which match regular expression $reg_exp_remove
  3. Writing new multi-architecture file $dst_lib

Usage example:
$ ./ sourceLib.a targetLib.a "MyRegularExpression" on Gist


Popular posts from this blog

Pattern: Riblets vs. VIPER

Engineering the architecture behind Uber's new rider app

Not being held back by our extensive codebase and previous design choices gave us the freedom where we otherwise would have made compromises. The outcome is the sleek new app you see today, which implements a new mobile architecture across both iOS and Android. Read on to learn why we felt the need to create this new architecture pattern, called Riblets, and how it helps us reach our goals.

The platforms share:

Core architectureClass namesInheritance relationships between business logic unitsHow business logic is dividedPlugin points (names, existence, structure, etc.)Reactive programming chainsUnified platform components
Each Riblet is made up of one Router, Interactor, and Builder with its Component (hence the name), and optional Presenters and Views. The Router and Interactor handle the business logic, while the Presenter and View handle the view logic.


Stetho - A Chrome debug bridge for Android applications

Stetho is a sophisticated debug bridge for Android applications. When enabled, developers have access to the Chrome Developer Tools feature natively part of the Chrome desktop browser. Developers can also choose to enable the optional dumpapp tool which offers a powerful command-line interface to application internals.

Facebook Github


WireMock is a flexible library for stubbing and mocking web services. Unlike general purpose mocking tools it works by creating an actual HTTP server that your code under test can connect to as it would a real web service.

It supports HTTP response stubbing, request verification, proxy/intercept, record/playback of stubs and fault injection, and can be used from within a unit test or deployed into a test environment.

Although it’s written in Java, there’s also a JSON API so you can use it with pretty much any language out there.