Xcode, Duplicate symbol _main

Ah..I figure out it's that I have multiple entries under Targets/Compiled Sources ( in newer XCode it's under Build Phases/Compile Sources ). I removed them and the problem is solved. The multiple entry thing probably has to do with Git merge.


It appeared that in my case I was importing a .m file instead of its .h counterpart. Solved by editing

#import "Tools.m"

into

#import "Tools.h"

I also had this problem and it was caused by code I imported from another project. I did a grep for "int main" in my project directory:

grep -nr "int main" .

and found

./main.m:13:int main(int argc, char *argv[])
./IMPORTED_DIR/main.m:13:int main(int argc, char *argv[])

the IMPORTED_DIR contained the extra main.m that was causing the error for me

I removed that file from the Project -> Targets -> Build phases -> Compile sources list and then it compiled