简体   繁体   中英

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?).

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?

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.

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.

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).

Because we built the static libs targeting iOS Device, the newly appearing .a nodes should appear in black in the project structure.

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. 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. But, I'm not sure about this, so I just wrote up the whole procedure that worked for me.

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