views:

80

answers:

1

During a refactor of an iOS project, I ran into this bear of a bug. During the linking phase, I get this message:

ld: duplicate symbol _OBJC_IVAR_$_TinCanViewController.currentViewController in /path/to/TinCanViewController-E98A666B7AF2673A.o and /path/to/TinCanViewController-E98A666B7AF2673A.o

As far as I can tell, it looks like it claims TinCanViewController-E98A666B7AF2673A.o is declaring the specified symbol twice; both paths are pointing to the exact same .o file. I ran nm on that specific file, and it only included that symbol once:

00008150 S _OBJC_IVAR_$_TinCanViewController.currentViewController

I ran nm on all the other .o files in the directory to see if they were somehow declaring this symbol, too, but they're not. This happens to any member I add to the TinCanViewController class - it's not specific to currentViewController.

I feel like I must be somehow linking against the class twice somehow, but I've pretty assiduously gone through and checked all references to this class. In the refactored version, there are basically none. The AppDelegate includes it, but right now it's basically just a passthrough class that loads another ViewController at the start. No other classes in the project include it.

Any suggestions on what might be causing this or how I might debug it better?

A: 

I think this is a bug with Apple's latest linker when creating universal static libraries. I can;t find the bug number currently, but this happens because it incorrectly generates armv6 and armv7 without disambiguating them.

To verify if this is the case, change the configuration to build only armv6 or amv7, and you won't have this problem.

psychotik
That sounded like a super promising solution (and may help someone else), but it doesn't seem to be fixing it for me… I set all configurations to armv7 (I'm working on an iPad-only app) and I'm still seeing the error, even after build-clean. I'm pretty sure I set it properly - this is what my configuration screen looks like:http://web.media.mit.edu/~dharry/configuration-armv7.pngIs there somewhere else I need to set it, too?
drewww
Hmm, that looks right to me. iPad can run armv6 - can you try and set it all to armv6 (and disable the "Build Active only" checkbox) and see if that helps? It *shouldn't* be any different than what you have, but it might be worth a shot.FWIW, I had to build the static libs that I use in my universal app as armv6 only, and Apple didn't have any issues approving it.
psychotik
I ended up knocking out the offending class, getting it to link successfully, and then rebuilt the class from scratch (linking every step of the way) and then when I had finally put all the pieces back in and connected them up again it was fine. Mysterious. I'd test the armv6 strategy, but the repository is a happier state now and I'm in no mood to revert back to the angry-no-linking phase. Thanks for the help! Marking as answered since it seems like a good general debugging suggestion, even if my problem was some other voodoo.
drewww
I deleted all of my build folders for all of my static libraries and restarted Xcode. That fixed my issue. Really weird.
Sam Soffes