I have an iOS app, which use liblzma. I am currently able to successfully write cross platform compile script to compile the source code into a .a file, and use the .a with headers in my project.
Now in iOS 8 and above, Apple start to support dynamic linking, so I was curious to see if I am able to use liblzma.dylib in my project instead of liblzma.a. But I failed.
Here's what I have done:
modify the compile script I previously used to compile liblzma.a. I changed --disable-shared to --enable-shared, and then use lipo to combine .dylib of each arch to a fat .dylib.
I removed the liblzma.a from my project, and added liblzma.dylib to my project
Build, success. But when running on device, I encountered the following error
dyld: Library not loaded: /Volumes/Data/Developer/build/xz-5.2.2/build/iOS/arm64/lib/liblzma.5.dylib Referenced from: /var/containers/Bundle/Application/AB7A063F-9C3F-4CEB-A757-965238947000/****.app/**** Reason: Incompatible library version:**** requires version 8.0.0 or later, but liblzma.5.dylib provides version 6.0.0 (lldb)
- I used tool to check the actual version of the newly built .dylib, this is what I got
/Volumes/Data/Developer/build/xz-5.2.2/build/iOS/Universal/lib/liblzma.5.dylib: /Volumes/Data/Developer/build/xz-5.2.2/build/iOS/x86_64/lib/liblzma.5.dylib (compatibility version 8.0.0, current version 8.2.0) /usr/lib/libSystem.dylib (compatibility version 1.0.0, current version 1226.10.1)
I have a few questions:
- Can I add dylib like this?
- Is liblzma.dylib actually copied to my iOS device when I run the app?
- Why the error message said liblzma.5.dylib provides version 6.0.0 whereas otool shows current version 8.2.0?
- I know for iOS 8.0+ apps to use dylib, that dylib also need to be signed. How do I do that?
Thanks!
x86_64and seems to conflict with the one you are setting asUniversal. I don't remember how its done, but I know it can be done (I've done it for a framework) but you have to manually set cross-compilation for it. Isn'tlzmaofficially supported? From your errors, its seems that lldb has a different version of the library whereas for iOS its yet another. - Ælex