简体   繁体   中英

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!

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM