Reference: http://blog.163.com/const_yixinyiyi/blog/static/180088172201211113333882/
Static library use target: (. a)
> Make a static library (available) (first three steps)
> Production simulator version and Real machine version (fourth step)
> Merge two versions (sixth step)
To create a static library step:
1. Select the type of file you want to create: Cocoa Touch Static Library (. a file)
2. Import the files that need to be encapsulated
Select Project to find the class that needs to be encapsulated in Compile sources, Build phases, target (Static library)
3. Setting up the compilation configuration
Compile editschem-> Select Run, select Info, set its build Configuration:release/debug
Select project: Project->build Setting, Code Signing, code Signing Identity Select its corresponding to the above, release or debug, set it to iOS Developer "Note that project is not targets"
4. Select Project->ios Device, click Run will generate ARM6,ARM7 static library, "Note: the static library generated at this time is applicable to the real machine, and not suitable for the simulator" If you need to generate I386 static library "simulator" Can be run again by selecting the simulator, "can not open with showinfinder, or just for the real machine" can be in the corresponding deriveddata of the corresponding project build, products The corresponding static library file is found in the debug-iphonesimulator.
Tip: You can lipo-inof the path/file name by command. A see if the file has arm or i386 conditions
5. After the compilation is successful, you can use
Note: The debug version differs from release version in the Debug version and released version, the depth difference is in the use of its dynamic library. It is a static library file with the corresponding simulator and the real machine mode.
Problems that may occur: Undefine Symbols for architecture i386
Problem Resolution: Using the wrong compiled. A lib, in the simulator, we need to build a static LIB based on the i386 schema, but this a file, compiled in fact, is ARM6 ARM7 architecture. Because we are using the show in Finder to point to a library of iOS device, not a library under the I386 emulator, if you want to compile i386 libraries, you need to be aware of the 4th operation, Then go to Deriveddata and find the static lib in the Iphonessimulator.
In fact, we open to the products debug file can see there are two folders:
Release-iphoneos or Debug-iphoneos: The library file is compiled from ARM6 ARM7.
Release-iphonesimulator: Inside is a file compiled from i386.
6. Combine the version supported by the emulator with the version supported by the real machine
Lipo-create path/emulator version. A path/real machine version. The path/static library name A-output want to put. A
After you have packaged it, you can see which version it supports:
Lipo-info path/merged static library name. A
Results show:
li****:D esktop mac$ lipo-info libdemo.a
Architectures in the Fat file:libdemo.a are:armv7 i386 arm64
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
IOS Static library production and usage issues