3
votes

I'm working on a project where I'm going to eventually have a library of code that will be used by multiple applications. In reading though the documentation it sounded like creating an XCode4 workspace and 2 projects (1 library, and 1 application) was the way to go.

I did this and everything appeared to be working just great. However, today I did a bunch of work on my library project and when I run my application to test my library changes it appears to always be including an older compiled version. I'm at a loss, I added my library as a build target in my applications scheme and XCode tells me it's compiling the library, but its always linking to an old version.

Any help is greatly appreciated. Am I missing something in how I set my workspace up? Is there a build step that will force linking to my newly compiled .a? I've even tried removing the dependency, cleaning, re-adding the dependency and building my app and I still get the same results.

3
Perhaps a specific compiled version was added in 'Link Binary With Libraries' under 'Build Phases'. - Peter DeWeese
Please update your question with a description of exactly how your dependencies are set up (or do you let Xcode auto-detect), how exactly your built .a product is linked to your app, etc. The details here are important. - Joshua Nozzi
Thanks for the comments, I got back to my code today and did a clean and re-build and everything is linking appropriately again. I think I must have been tired and doing something stupid yesterday. To answer you question Joshua, I am letting XCode auto-detect. - Rob Booth
Good news. Please post this as an answer and mark it accepted. A good SO citizen should clean up after themselves. :-) - Joshua Nozzi

3 Answers

2
votes

I ran into same problem and my solution was to add

rm -f BUILT_PRODUCTS_DIR/$EXECUTABLE_PATH

to the build -> pre-actions section (edit scheme, expand build and add pre-action). Under Provide build settings from make sure to select your target project. This will ensure correct env vars are configured when your script runs. I'm using XCode 4.5.1.

1
votes

Turns out XCode was doing everything right, and I wasn't. Another clean all and recompile and everything is working as expected.

1
votes

Additional information about this type of issue here: Static libraries in Xcode 4