Create one static library for iOS and a simulator for distribution

If you are creating a static library for iOS, do you need to distribute header files with it, or is there another way to make it work?

Currently, I have one my_lib.a file for the device and the simulator, but when I drag it to another test application to use it, it says that it cannot find the header and that all the places where I use it, the code not announced. Therefore, I believe that I am either doing something wrong, or I also need to send the appropriate header files.

History of my process:

I saw two guides for creating a static library for the device and the simulator. One on this site: Create a live static library (device + simulator) using Xcode and SDK 4+

and one here: http://mark.aufflick.com/blog/2010/11/19/making-a-fat-static-library-for-ios-device-and-simulator

I used the second site to just try it out. I am also a little curious if I did this right. I just went into the Release-iphone folders (os | simulator) and found .a in ios one and .o in the simulator.

+7
ios static objective-c static-libraries
source share
2 answers

The short answer is yes, you need to pack the header files with your static library. You must pack the header files with any library, in fact, dynamic or static. The library itself contains compiled code, but you should still tell the compiler about the identifiers in the library, so when it compiles your code, it knows that they exist.

If you don't care, you can easily pack a static library into a static structure. You simply create the same directory structure as in the dynamic structure, with your .a file instead of the .dylib (or .so) file. Frames contain a directory for headers, so you can distribute binary files and headers as one package, and you can easily import headers from the framework without violating the assembly settings for additional header paths.

+3
source share

Just in case, this is useful - I followed Ray Wenderlich's instructions from here and was able to create an iOS framework that supported several architectures at once (including the simulator). The instructions are too long to just copy-paste here.

0
source share

All Articles