XCode doesn't realize a library has changed unless you force your project to build.

Nibbie
Posts: 4
Joined: 2009.06
Post: #1
Hi guys,

I'm fairly new to mac development but I've been using XCode without much fuzz for the past two months. But I do have one issue that has been annoying me since the beginning that I don't seem to be able to figure out for myself and didn't had any luck googling it either, so I'm turning to this fine forum for assistance.

I'm working on a mac carbon game that depends on a certain static library that I've created myself. So I'm always working on two projects at the same time, one is the game and the other one is the library. The thing is that if I change some code on the library, build it and then build the game, XCode doesn't seem to be capable of figuring out that the library has changed, so it just runs the game again like nothing has changed. The only way I can force it to link against the new library is changing some file on the game project.

I've also tried cross-project referencing the library's project to the game project but the same thing happens. Unless there's a change on the game project, XCode doesn't seem to bother to check if the library has changed. I'm using XCode 3.1.2 by the way. Any thoughts or suggestions are welcome.

Thanks!
Nicolas.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #2
It works for me and I don't even have projects cross-linked. Xcode is a strange animal though. I don't have any solid ideas up-front, but perhaps maybe having zero-link enabled might be an issue? Do you have zero-link enabled? I dunno... It's a shot in the dark guess...
Quote this message in a reply
Member
Posts: 257
Joined: 2004.06
Post: #3
As a general rule of thumb, I turn Zero-link off. It usually causes more trouble than it's worth.

The brains and fingers behind Malarkey Software (plus caretaker of the world's two brattiest felines).
Quote this message in a reply
⌘-R in Chief
Posts: 1,260
Joined: 2002.05
Post: #4
It always works for me, whether there's a project dependency or not. I don't know if you've done it properly, so I'll just note that you need to add the library target as a dependency in your game's target so that it'll always build the library as needed.
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2009.06
Post: #5
Hey guys, thanks for your responses.

I do have zero-link disabled, I've read it is problematic.

I forgot to mention it in the previous post but I already tried adding the library to the game target as Seth suggested. That does indeed solves the problem, but it creates a new one, because I have both a debug and a release version of the library, so I cannot add both to the target.

The way I'm linking to the right library now is adding -llibraryname to "Other Linker Flags". That way I can link to the debug and release versions of the library for the respective game configuration. I didn't find any way to do that adding libraries to the target, since it seems any library you add this way gets linked for both configurations. How would you deal with that case?

Thanks again.
Quote this message in a reply
Moderator
Posts: 3,577
Joined: 2003.06
Post: #6
What I do is change the library project to build both the debug and release version in the same location, just in the build folder, not in the release or debug folders. That way the app that uses the library has no idea which one it's working with and links correctly either way (i.e. it doesn't care if the lib is debug or release, only that the lib exists in the location you said it'd be in, and since debug and release version of the same lib build right in the build folder, whatever happens to be there at the time is the one it uses).
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2009.06
Post: #7
Thanks Jake for your suggestion. That would work but unfortunately it is not practical for me right now. Any other ideas out there?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  SDL Project Stationary for Xcode Evan Stallings 11 4,289 Jul 9, 2013 05:17 PM
Last Post: Evan Stallings
  Converting unix SDL project to xcode Dominus 0 4,249 Jan 3, 2011 04:46 AM
Last Post: Dominus
  Debugging in XCode without project? mattz 5 5,944 Dec 5, 2009 01:21 PM
Last Post: bronxbomber92
  xcode build optimizations NelsonMandella 5 7,089 Jul 24, 2009 06:39 AM
Last Post: Oddity007
  I would like to be able to browse an xCode project on my PC aerospaceman 8 7,075 Jun 29, 2009 07:11 PM
Last Post: aerospaceman