iOS static library production

There is a problem with a static library call in the company's project. Since this library is left by the predecessors, I don't know the implementation process. Fortunately, the source code is available, and the problem is solved after careful study. Then you need to recreate the static library .a, here just record the steps of the production process.

1. Open a new project in Xcode and select "Cocoa Touch Static Library"

 

2. Import the source code that needs to be packaged into a static library and import the newly created project. (Note: If you import a third-party static library, do not check target)

 

3. Configure the minimum supported version (configured here according to personal needs)

 

 

4. Set to adapt to all simulator architectures, search for "Build Active Architecture Only", set to NO

 

 5. Set up the compilation environment Debug and Release

 Select "Release" here

 

 

6. Configure the .h and .m files

 

 

 

 

7. Select the simulator and the real machine, compile once respectively, "command+B"

 

 

After compiling the simulator and the real machine separately, libtest.a in the Products directory changes from red to black,

 

 

Select libtest.a, right-click "show in Finder", you will see two files starting with Release (if step 5 is set to Debug, you will see two files starting with Debug), and create a new folder "lib" on the desktop , and copy the files beginning with the two Releases to the "lib" folder.

 

8. Open the terminal, first enter the lib directory, and then execute the merge.a command

cd drag the lib folder here
Drag libtest.a under lipo -create Release-iphoneos to this space and drag libtest.a under Release-iphonesimulator to this -outputlibtest.a

See that there is a merged libtest.a in the lib folder.

 

9. Terminal input, verify the appropriate model

lipo -info drag in the merged libtest.a just now

 

 

10. Create a new folder "libTestSDK", copy all the files in the Release-iphoneos directory to the folder "libTestSDK", and then replace the merged libtest.a with libtest.a in the folder "libTestSDK".

 

11. This completes the static library production, you can import libTestSDK into the required project and use it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325251853&siteId=291194637