To build the static library:
- Create a static library project in Xcode
- Add all the .c and .h file to the project
- Compile
The easiest way to use this library is then to add this static library project to you application project. This avoids having to worry about creating fat libraries (i.e. libraries with code for both the simulator and device).
To add the static library project to your application project:
- Choose File > Add Files to ""...
- Add the .xcodeproj for your static library
- Click on your app's .xcodeproj in the Project Navigator to show build options
- Click on your app's target and choose the "Build Phases" tab.
- Expand the "Link With Binaries Section"
- Click the '+' button
- Expand the "Workspace" section (you should see your library, a .a file, there)
- Click on your library and you should be good to go.
Apologies for excruciating level of detail above, but somehow people always seem to forget to do steps 4-8 and then they wonder why they are getting link errors!
Xcode will not be able to find the headers for your library. You can either add the public headers to your project as you would any other header file or set the "Header Search Paths" in your build settings.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…