I'm getting the following error in Xcode 3.2.1 on Snow Leopard 10.6.2 whenever I try to compile any iPhone application generated by Appcelerator Titanium. However, the build error only appears when I select iPhone simulator on the architecture menu and if I select the iPhone device, I am able to run the app on my device .
Further more, the iPhone simulator launches successfully and executes the program directly from the Titanium environment which uses Xcode to build .
Why is this happening ?
ld: duplicate symbol _main in Resources/libTitanium.a(main.o) and /Users/prithviraj/Documents/project/Final/build/iphone/build/Final.build/Debug-iphonesimulator/Final.build/Objects-normal/i386/main.o collect2: ld returned 1 exit status Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
Delete
/Users/{username}/Library/Developer/Xcode/DerivedData
folder and build again.Based off what I can tell from these other answers, I'm going to need to be remove a bunch of
main
methods.But to do that easily I first need to remove all the gd comments from my files because they are assiduously documented with comments at nearly every other line
This regular expression matches all C multi-line comments including their delimeters & may help you on your journey
I can't tell you why this is happening, but I can suggest a workaround. When I commented out the entire contents of the main.m file that was generated for my Titanium project, I was able to compile successfully and run on the Simulator. Let me know if that works for you.
I just spent a couple hours battling this one. It was because I was using the -all_load linker flag. If you are using that flag to get around the category bug, there are some other solutions -- see here.
This happened to me for 2 reasons:
1: Class A calls class B and both had imported the same class. Fix it by importing the class in .m file.
2: Two classes have a constant with the same name (even if the constant is defined in the .m file). Fix it by changing the name of the constants.
I had a similar problem. A unit test class was accidentally included in my build. If you search your project for "main(" you'll probably find the duplicate functions.