Static library Xcode projects generated with Producer don't have "link binary with library" option available


I have to warn you I’m not an Xcode expert and I’m having a very annoying with it at the moment.
I have a static library project originally built from Jucer on which I have added a new target for unit tests (gtest). At first everything seemed to work properly but I quickly noticed that I was’t in fact running the latest version of my library in the unit tests. In fact, no matter what I was fixing in an existing method always ended up in a failed test. While debugging I noticed that the debug breakpoints were “aliased”, like if what I was writing wasn’t linked into the final google test executable. On the other hand, when Xcode compiles the library it will complain if anything is wrong with the source code… so Xcode does compile the code I have in front of my eyes at one point.
So it seems that in the end Xcode is linking some sort of zombie and old version of the static library only during the final linking… which I couldn’t find until I changed this “derived data” folder in Xcode’s global preferences to output all the build artefacts next to my project.

I tried to clean thousand times, to add/remove the library in “link binary with libraries”… totally running out of idea. Now since I changed this Derived Data location it just doesn’t find the library anymore. Seems like a progress but I cannot explain what is going on.

The only thing I’ve noticed is that Projucer doesn’t seem to make a regular configuration for static library project. In Building Phases it doesn’t have any “Link binary with libraries” option… I wonder if it would be behind this very annoying side-effect?

Sorry, like I said I’m unfortunately not an Xcode expert so let me know if I can paste any hint here.

Thank you very much all!

Are you rebuilding the static library target before building and running the tests each time?

I would do the following:

  1. Clean everything.
  2. Build the static library.
  3. Look at the build log to find out where the library is created. If this is somewhere strange then change it with the Derived Data option. Go back to step 1.
  4. In your tests target add your library on the “General” pane and make sure the path to your library from step 3 is in “Library Search Paths” on the “Build Settings” pane.
  5. Build your tests and look in the build log to find which library you are linking. This should be the one from step 3.