Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

duplicate symbol _OBJC_METACLASS_$_ClassName

I am trying to run my cocos2d application and facing this error, as I have recently upgraded my sdk to 4.2 and my cocos2d to 0.99.5.

I tried to clean my project even change the Target ios Deployment but error remains the same. Also rename the className aswell in order to avoid duplication from Library classes names of cocos2d.

ld: duplicate symbol _OBJC_METACLASS_$_MenuSceneNew in /Users/umaidsaleem/Desktop/functionalityTest/build/Debug-iphonesimulator/libcocos2d libraries.a(MenuScene.o) and /Users/umaidsaleem/Desktop/functionalityTest/build/functionalityTest.build/Debug-iphonesimulator/functionalityTest.build/Objects-normal/i386/MenuScene.o

like image 221
user366584 Avatar asked Mar 17 '11 10:03

user366584


4 Answers

Another rather simple thing to check is that you did not accidentally #import a .m file instead of a .h header file.

Happened to me.

like image 68
derekv Avatar answered Oct 06 '22 20:10

derekv


You are linking the file MenuScene.m twice. You apparently have it in a static library and also in your main application.

like image 34
JeremyP Avatar answered Oct 06 '22 21:10

JeremyP


Another reason for this, for those out there who did the same as I just did, might be that you re-created a managed object class. By doing that and choosing another group in the project structure, you accidentally create another reference to the same files.

I ended up with two references for header and implementation in both the root of the project and in my model group. Removing the topmost references to .h and .m files got rid of the linking failure.

like image 37
Egil Rausner Avatar answered Oct 06 '22 22:10

Egil Rausner


Sometimes Core Data inserts AnyProjectNameModel.xcdatamodeld to the Compile Sources of the Build Phases. Check it and delete it and everything is run again... The error message just indicates the generated ManagedObjects... The correct place for the AnyProjectNameModel.xcdatamodeld is the Copy Bundle resources in the Build Phases. enter image description here

like image 26
BootMaker Avatar answered Oct 06 '22 20:10

BootMaker