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:
Usage example:
$ ./strip-lib.sh sourceLib.a targetLib.a "MyRegularExpression"
strip-lib.sh on Gist
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:
- Extracting architecture slices of multi-architecture file $src_lib
- Excluding library archives which match regular expression $reg_exp_remove
- Writing new multi-architecture file $dst_lib
Usage example:
$ ./strip-lib.sh sourceLib.a targetLib.a "MyRegularExpression"
strip-lib.sh on Gist
Comments
Post a Comment