简体   繁体   English

XCode Project:如何将子项目构建为静态库?

[英]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 在products文件夹中找到子项目的.a文件,将它们复制到主项目中
  3. copy all .h files for sub-projects into a folder in main projects 将子项目的所有.h文件复制到主项目的文件夹中
  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... 不,你不需要做任何事情因为Xcode会为你做所有事情......

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. 它们理想情况下应该是独立编译的独立库,您只需在主项目中添加.a文件和主头文件。 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. 您只需要更新.a文件或.h,如果他们更改了......是的,当您想要将应用程序提交到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. 所有问题都是您遵守的iOS目标和基础SDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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