简体   繁体   English

带应用和静态库的Xcode 4项目-构建时干净的库

[英]Xcode 4 project w/app & static library- clean library on build

I have an Xcode 4 project that has my iOS app and a static library (which is a separate project, but included in the app's project, still with me?). 我有一个Xcode 4项目,该项目具有我的iOS应用程序和一个静态库(这是一个单独的项目,但是包含在应用程序的项目中,还和我在一起吗?)。

Okay so anytime I make a change to the static library, in order to see the results when running the app, I have to do a clean and then run. 好的,所以无论何时我对静态库进行更改,为了在运行应用程序时看到结果,我都必须先清理然后再运行。 Is there a way to have it automatically clean the static lib before building the app's target? 有没有办法让它在构建应用程序目标之前自动清除静态库?

Is the static library's .a filename colored red in the project structure? 静态库的.a文件名在项目结构中是否显示为红色

Step one: make a backup of your project if you don't have one already :) 第一步:如果还没有备份项目,请备份:)

Step two: try what worked for me: 第二步:尝试对我有用的方法:

Remove the static library red .a nodes from the project structure. 从项目结构中删除静态库红色.a节点。

Removing these nodes will break the linkage between apps and libs that you've established in your project settings (under "Build Phases > Link Binary with Libraries"), but don't worry -- you can set them back up later. 删除这些节点将破坏您在项目设置中建立的应用程序和库之间的链接(在“构建阶段>使用库链接二进制文件”下),但是请不要担心-您可以稍后将其备份。

Now go through all your static library projects one by one and build them individually, targeting "iOS Device" (as opposed to Simulator.) It is important to target iOS Device -- this is the magic step. 现在,一个一个地遍历所有静态库项目,并分别针对“ iOS Device”(而不是Simulator)分别构建它们。以iOS Device为目标很重要-这是神奇的一步。

Once all your static libraries have been built for iOS Device, then go back through your project settings and re-establish the link between your Apps and your Libs (eg by going to "Build Phases > Link Binary with Libraries" in the App's project settings). 为iOS设备构建完所有静态库后,请返回您的项目设置并重新建立您的应用程序和库之间的链接(例如,通过转到应用程序项目设置中的“构建阶段>使用库链接二进制文件”) )。

Because we built the static libs targeting iOS Device, the newly appearing .a nodes should appear in black in the project structure. 因为我们针对iOS设备构建了静态库,所以新出现的.a节点在项目结构中应显示为黑色。

Changes to the static library source code should now be picked up by the Build (or Run) process for your main App, even if you didn't clean or modify the main App. 现在,即使您没有清理或修改主应用程序,对静态库源代码所做的更改也应由主应用程序的构建(或运行)过程获取。 If you're like me, and the bulk of your development is inside a static library, and you rarely make changes to the app project, this is a HUGE headache saver. 如果您像我一样,并且大部分开发工作都在静态库中,并且您很少对应用程序项目进行更改,那么这将为您节省很多时间。

If you ever run a Clean while targeting "iOS Device", the static lib nodes may go red again. 如果您曾经在定位“ iOS设备”时运行“清理”,则静态lib节点可能会再次变为红色。 I'm not sure if this will break things again. 我不确定这是否会再次破坏事情。

It may not actually be necessary to remove nodes / break the linkage to fix the build. 实际上可能不需要删除节点/断开链接以修复构建。 It might be enough to just build each library targeting iOS Device. 仅构建针对iOS设备的每个库就足够了。 But, I'm not sure about this, so I just wrote up the whole procedure that worked for me. 但是,我对此不确定,所以我只写了对我有用的整个过程。

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

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