You are on page 1of 4

How to compile native C codes to a library for iOS development in XCode

For iOS development, sometimes you want to use a existed native C codes for help. Objective
a superset of C so its easy to combine C codes in your Objective
it only support compiling C code to a static lib
In this tutorial, I take an open source project
demo how to compile it into a static library in Xcode.

Environments
* Xcode 4.1
* MacOSX Lion
* mosquitto 0.13

Tutorial
1. Download mosquito form <
the whole directory structure:

2. Create a new pro
* Choose static type
How to compile native C codes to a library for iOS development in XCode
For iOS development, sometimes you want to use a existed native C codes for help. Objective
a superset of C so its easy to combine C codes in your Objective
it only support compiling C code to a static lib
In this tutorial, I take an open source project
demo how to compile it into a static library in Xcode.
Environments
* Xcode 4.1
* MacOSX Lion
* mosquitto 0.13
Tutorial
1. Download mosquito form <
the whole directory structure:
2. Create a new pro
* Choose static type
How to compile native C codes to a library for iOS development in XCode
For iOS development, sometimes you want to use a existed native C codes for help. Objective
a superset of C so its easy to combine C codes in your Objective
it only support compiling C code to a static lib
In this tutorial, I take an open source project
demo how to compile it into a static library in Xcode.

1. Download mosquito form <http://mosquitto.org/files/source/mosquitto
the whole directory structure:
2. Create a new project by template C/C++ Library
* Choose static type
How to compile native C codes to a library for iOS development in XCode
For iOS development, sometimes you want to use a existed native C codes for help. Objective
a superset of C so its easy to combine C codes in your Objective
it only support compiling C code to a static lib
In this tutorial, I take an open source project
demo how to compile it into a static library in Xcode.
http://mosquitto.org/files/source/mosquitto
ject by template C/C++ Library
How to compile native C codes to a library for iOS development in XCode
For iOS development, sometimes you want to use a existed native C codes for help. Objective
a superset of C so its easy to combine C codes in your Objective
it only support compiling C code to a static library by now.
In this tutorial, I take an open source project MQTT message broker
demo how to compile it into a static library in Xcode.
http://mosquitto.org/files/source/mosquitto

ject by template C/C++ Library
How to compile native C codes to a library for iOS development in XCode
For iOS development, sometimes you want to use a existed native C codes for help. Objective
a superset of C so its easy to combine C codes in your Objective-C project. But for a library usage,
rary by now.
message broker Mosquitto
http://mosquitto.org/files/source/mosquitto

How to compile native C codes to a library for iOS development in XCode
For iOS development, sometimes you want to use a existed native C codes for help. Objective
C project. But for a library usage,
Mosquitto as an example to
http://mosquitto.org/files/source/mosquitto-0.13.tar.gz
How to compile native C codes to a library for iOS development in XCode
For iOS development, sometimes you want to use a existed native C codes for help. Objective-C is
C project. But for a library usage,
as an example to
0.13.tar.gz>. Here is
C is
C project. But for a library usage,
as an example to
>. Here is
3. Import(or just drap and drop) C codes(include .h and .c) to the project
4. Check the Build settings in project
* Base SDK => Latest iOS
* Architectures => Standard(armv6 armv7)
* Supported Platforms should include iphonesimulator iphoneos
3. Import(or just drap and drop) C codes(include .h and .c) to the project
4. Check the Build settings in project
* Base SDK => Latest iOS
* Architectures => Standard(armv6 armv7)
Supported Platforms should include iphonesimulator iphoneos
3. Import(or just drap and drop) C codes(include .h and .c) to the project
4. Check the Build settings in project
* Base SDK => Latest iOS
* Architectures => Standard(armv6 armv7)
Supported Platforms should include iphonesimulator iphoneos
3. Import(or just drap and drop) C codes(include .h and .c) to the project
4. Check the Build settings in project
* Architectures => Standard(armv6 armv7)
Supported Platforms should include iphonesimulator iphoneos
3. Import(or just drap and drop) C codes(include .h and .c) to the project
* Architectures => Standard(armv6 armv7)
Supported Platforms should include iphonesimulator iphoneos

3. Import(or just drap and drop) C codes(include .h and .c) to the project

Supported Platforms should include iphonesimulator iphoneos
3. Import(or just drap and drop) C codes(include .h and .c) to the project

5. Check the Build Phases in targets
* Copy Headers => Add or move(from Project) the header files that should be referenced to
Public
6. Select Scheme respectively for iOS Device a
resolve the errors
* Select iOS Device will make product(.a) in <Debug/Release>
* Select iPhone/iPad simulator will make product(.a) in <Debug/Release>
* Right
5. Check the Build Phases in targets
* Copy Headers => Add or move(from Project) the header files that should be referenced to
Public
6. Select Scheme respectively for iOS Device a
resolve the errors
* Select iOS Device will make product(.a) in <Debug/Release>
* Select iPhone/iPad simulator will make product(.a) in <Debug/Release>
* Right-click the product n
5. Check the Build Phases in targets
* Copy Headers => Add or move(from Project) the header files that should be referenced to
6. Select Scheme respectively for iOS Device a

* Select iOS Device will make product(.a) in <Debug/Release>
* Select iPhone/iPad simulator will make product(.a) in <Debug/Release>
click the product name and click Show in Finder to locate files
5. Check the Build Phases in targets
* Copy Headers => Add or move(from Project) the header files that should be referenced to
6. Select Scheme respectively for iOS Device a
* Select iOS Device will make product(.a) in <Debug/Release>
* Select iPhone/iPad simulator will make product(.a) in <Debug/Release>
ame and click Show in Finder to locate files
* Copy Headers => Add or move(from Project) the header files that should be referenced to
6. Select Scheme respectively for iOS Device and iPhone/iPad Simulator for Build(Cmd+b) and
* Select iOS Device will make product(.a) in <Debug/Release>
* Select iPhone/iPad simulator will make product(.a) in <Debug/Release>
ame and click Show in Finder to locate files
* Copy Headers => Add or move(from Project) the header files that should be referenced to
nd iPhone/iPad Simulator for Build(Cmd+b) and
* Select iOS Device will make product(.a) in <Debug/Release>-iphoneos
* Select iPhone/iPad simulator will make product(.a) in <Debug/Release>


ame and click Show in Finder to locate files
* Copy Headers => Add or move(from Project) the header files that should be referenced to
nd iPhone/iPad Simulator for Build(Cmd+b) and
iphoneos
* Select iPhone/iPad simulator will make product(.a) in <Debug/Release>-iphonesimulator
ame and click Show in Finder to locate files
* Copy Headers => Add or move(from Project) the header files that should be referenced to
nd iPhone/iPad Simulator for Build(Cmd+b) and
iphonesimulator



7. Now you can copy the public header files and static library to the next project you want to use it.
Notes:
1. Only static library(product will be the .a format) support for iOS
2. The compiled library

7. Now you can copy the public header files and static library to the next project you want to use it.
Notes:
1. Only static library(product will be the .a format) support for iOS
2. The compiled library

7. Now you can copy the public header files and static library to the next project you want to use it.
1. Only static library(product will be the .a format) support for iOS
2. The compiled library for simulator and physic device is different
7. Now you can copy the public header files and static library to the next project you want to use it.
1. Only static library(product will be the .a format) support for iOS
for simulator and physic device is different
7. Now you can copy the public header files and static library to the next project you want to use it.

1. Only static library(product will be the .a format) support for iOS
for simulator and physic device is different
7. Now you can copy the public header files and static library to the next project you want to use it.
1. Only static library(product will be the .a format) support for iOS
for simulator and physic device is different
7. Now you can copy the public header files and static library to the next project you want to use it. 7. Now you can copy the public header files and static library to the next project you want to use it.

7. Now you can copy the public header files and static library to the next project you want to use it.