3

Sorry I know this has been covered all over the place, only I can't fix this to save my life.

If someone could explain clearly what I might have done and what I might be able to do to fix this I would be forever grateful.

Here is my error:

Command /Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1

ld: duplicate symbol _OBJC_IVAR_$_sunnyHillsTL._tileMap in /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos/libcocos2d libraries.a(sunnyHillsTL.o) and /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Intermediates/workingTitle.build/Debug-iphoneos/workingTitle.build/Objects-normal/armv7/sunnyHillsTL.o


Ld /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos/workingTitle.app/workingTitle normal armv7
    cd "/Users/kahanejosh/Documents/iPhone:Mac Dev/Working Title/workingTitle"
    setenv IPHONEOS_DEPLOYMENT_TARGET 3.0
    setenv PATH "/Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin:/Xcode 4/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    "/Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2" -arch armv7 -isysroot "/Xcode 4/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk" -L/Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos -F/Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos -filelist /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Intermediates/workingTitle.build/Debug-iphoneos/workingTitle.build/Objects-normal/armv7/workingTitle.LinkFileList -dead_strip -all_load -ObjC -miphoneos-version-min=3.0 -framework CoreGraphics -framework Foundation -framework OpenGLES -framework QuartzCore -framework UIKit -framework AudioToolbox -framework OpenAL -lz -framework AVFoundation "-lcocos2d libraries" -o /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos/workingTitle.app/workingTitle

ld: duplicate symbol _OBJC_IVAR_$_sunnyHillsTL._tileMap in /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Products/Debug-iphoneos/libcocos2d libraries.a(sunnyHillsTL.o) and /Users/kahanejosh/Library/Developer/Xcode/DerivedData/workingTitle-cawhuhbkmwcesmbqxvkbkbatdbze/Build/Intermediates/workingTitle.build/Debug-iphoneos/workingTitle.build/Objects-normal/armv7/sunnyHillsTL.o
collect2: ld returned 1 exit status
Command /Xcode 4/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2 failed with exit code 1
Josh Kahane
  • 16,765
  • 45
  • 140
  • 253

3 Answers3

3

It looks like you have two targets set up and your source is getting used in both. So, you create a static library with the sunnyHillsTL class that gets put into libcocoas2d libraries.a and then you are using the same object file as well. Either don't directly use the class in your target (don't add the class to the target) if you're using the library, or don't have this class be compiled as part of the static library.

Jason Coco
  • 77,985
  • 20
  • 184
  • 180
  • Well my two targets are, the app and the cocos2d library which has to be included as its a game created with cocos2d. Since using Xcode 4 (GM) it gives me an option to build the library or app (which seems silly). Why build the library, its part of the app. I have tried opening and cleaning and building in Xcode 3.2.x and still no luck. – Josh Kahane Feb 28 '11 at 23:08
  • @Josh Kahane: The library is including your sunnyHillsTL code. Change it so that the library target does not include that implementation file. Or, if it's required by other code needed to build the library, do not include it in the main target. Your problem is that it's being built and linked by both targets, hence your duplicate symbols. – Jason Coco Feb 28 '11 at 23:12
  • Got it! Thanks! I deleted the file from the cocos library (wasn't meant to be there) and now works, thanks! – Josh Kahane Feb 28 '11 at 23:14
  • 1
    @Josh Kahane: In Xcode4, click on the file from the file-list navigator and make sure your right-side utility panel is open. Click the the 'file inspector utility' (looks like a little piece of paper) and look for the 'Target Membership' section. There you will see the targets it's included in (certainly both the static library *and* the main target). – Jason Coco Feb 28 '11 at 23:19
1

Seems like you have two instance variables named «tileMap» in your «sunnyHillsTL» class...

Macmade
  • 52,708
  • 13
  • 106
  • 123
  • Thats what I initially thought but after multiple thorough checks for the life of me I have no duplicate declarations of it in that class. – Josh Kahane Feb 28 '11 at 22:54
-5

install Command Line Tools from your Xcode. in Xcode -> Preferences -> Downloads -> Components ->Command Line Tools

losingle
  • 143
  • 1
  • 2
  • 9