Question

I have a third party iOS library that links and runs fine in my app and in the simulator. I am trying to extract the object files from it in order to integrate it with another piece of third party software that repackages the object files with their own code. However, I am unable to extract the object files via ar; I consistently get the error, "Inappropriate file type or format".

The library in question is a fat library with armv7, armv7s, and i386 included. Stock lipo doesn't know about armv7s on my machine, but Xcode's does:

$ lipo -info library.a
Architectures in the fat file: library.a are: armv7 (cputype (12) cpusubtype (11)) i386 
$ xcrun -sdk iphoneos lipo -info library.a 
Architectures in the fat file: library.a are: armv7 armv7s i386 

I can successfully thin it out with lipo:

$ xcrun -sdk iphoneos lipo library.a -thin armv7 -output library-armv7.a
$ xcrun -sdk iphoneos lipo -info library-armv7.a 
Non-fat file: library-armv7.a is architecture: armv7

However, even after thinning it out, I can't manipulate it with ar:

$ xcrun -sdk iphoneos ar -tv library-armv7.a 
ar: library-armv7.a: Inappropriate file type or format
$ xcrun -sdk iphoneos ar -xv library-armv7.a 
ar: library-armv7.a: Inappropriate file type or format

I'm on OS X 10.8.2, Xcode 4.6 with development tools installed.

Is there any additional step I can take for this troublesome library?

Update in response to Martin's comment

file shows the following:

$ file library.a
library.a: Mach-O universal binary with 3 architectures
library.a (for architecture armv7): Mach-O object arm
library.a (for architecture cputype (12) cpusubtype (11)):  Mach-O object arm
library.a (for architecture i386):  Mach-O object i386
$ file library-armv7.a 
library-armv7.a: Mach-O object arm

Looks like it's not a library at all!

Was it helpful?

Solution

The "library" is not actually a library, but is an object file itself. There is nothing further to extract.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top