Reputation: 4946
I have the following log output when running my application the iOS5 simulator. Both locations are the same. I get the following error for just about every class that is part of JSONKit.
Class JKSerializer is implemented in both /Users/myHomeDir/Library/Application Support/iPhone Simulator/5.0/Applications/33E6C55B-4883-48FF-BEFF-3FBA9C071CAB/MyApp.app/MyApp and /Users/myHomeDir/Library/Application Support/iPhone Simulator/5.0/Applications/33E6C55B-4883-48FF-BEFF-3FBA9C071CAB/MyApp.app/MyApp. One of the two will be used. Which one is undefined.
If this is appropriate, I have just ran a complicated merge, and I would prefer to not have to revert back to a previous version.
Any ideas on how this error occurs, how to prevent it, and how to fix it?
Upvotes: 0
Views: 1003
Reputation: 2376
Check to see if JSONKit is in a third party library that you are linking against.
There is a detailed post describing how to debug this very issue.
Upvotes: 1
Reputation: 26662
It's because the JSONKit.m
implementation file is a member of more than one target and one of those targets has been included as a dependency on the other.
So, for example, checking target membership:
Here you can see that the file is a member of Pods-UnitTests
and Pods
.
This reflects the settings in Build Phases -> Compile Sources for each respective target.
Being a member of two targets isn't a problem per se. Rather the issue is that one of these targets is a dependency on the other. So Pods-UnitTests
has a dependency on Pods
. So, when you check the build transcript for unit tests, if you search for JSONKit.m
, you'll find it twice. Once for libPods.a, and again for the Unit Tests target.
If you're not using CocoaPods then the solution is simply to remove the JSONKit.m
file so it is only compiled once.
If you are using CocoaPods then I'm not sure what the solution is because although you don't want to compile the file twice, you will no doubt need to import the headers somewhere in your unit test code. As yet I'm not sure how to do that.
Here are some references:
https://github.com/CocoaPods/CocoaPods/issues/115
http://sealedabstract.com/code/tired-of-getting-mach-o-linker-errors-when-unit-testing/
Upvotes: 3