3

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.

Rob Booth
  • 1,792
  • 1
  • 11
  • 22
  • 2
    Perhaps a specific compiled version was added in 'Link Binary With Libraries' under 'Build Phases'. – Peter DeWeese Mar 20 '11 at 01:41
  • 2
    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 Mar 20 '11 at 14:56
  • 1
    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 Mar 21 '11 at 04:37
  • 1
    Good news. Please post this as an answer and mark it accepted. A good SO citizen should clean up after themselves. :-) – Joshua Nozzi Mar 21 '11 at 18:54

3 Answers3

2

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.

halex
  • 16,253
  • 5
  • 58
  • 67
1

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

Rob Booth
  • 1,792
  • 1
  • 11
  • 22
1

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

Community
  • 1
  • 1
TomSwift
  • 39,369
  • 12
  • 121
  • 149