hzxu
hzxu

Reputation: 5823

XCode Project: how to build sub-projects as static libraries?

I need to build sub-projects as static libraries, not too sure how I should do it, should I:

  1. Compile all sub-projects one by one (or compile the main project once?)
  2. Find .a files for sub-projects in products folder, copy them to main project
  3. copy all .h files for sub-projects into a folder in main projects
  4. remove all sub-projects

are the above steps correct?

Also, do I need to compile them in release(or debug) mode, and for simulator and device respectively?

Thanks!

Upvotes: 3

Views: 3355

Answers (2)

Paresh Masani
Paresh Masani

Reputation: 7504

I use static library in my project. The steps you mentioned are correct except remove all sub projects? Why do you need to have sub projects at all. They all ideally should be independent libraries compiled independently and you just add .a file and main header files in the main project. If you do this you don't need to update your main project when your static library changes. You just need to update .a file or .h incase they changed....and yes you will need to compile static libraries in release mode when you want to submit your App to appstore. Simulator and device really doesn't matter as it's not going to run. It's all matter is iOS target and base SDK that you complied against.

Upvotes: 0

borrrden
borrrden

Reputation: 33421

No, you don't need to do any of that because Xcode will do it all for you...

Basically, just drag the library project in, set the dependencies and be done: See this page for details.

Upvotes: 5

Related Questions