Xcode, Duplicate symbol _main

前端 未结 10 746
抹茶落季
抹茶落季 2020-11-30 03:14

I have duplicate symbol _main.

The problem is it says \"Duplicate symbol _main in /Users/.../i386/main-B9843B6026D6EFA4.o and /Users/.../i386/main-B9843B6026D6EFA4.o

相关标签:
10条回答
  • 2020-11-30 03:39

    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"
    
    0 讨论(0)
  • 2020-11-30 03:40

    In my case, I declared an NSString in my constants file (imported by many classes) but forgot to define it as static!!

    e.g. NSString* PARAMS = @"paramA"; should be: static NSString* PARAMS = @"paramA";

    Reading the full error message allowed me to figure this out: "Duplicate symbol PARAMS". Don't be afraid and try to understand error messages! Sometimes they might even tell you exactly what you did wrong.

    0 讨论(0)
  • 2020-11-30 03:41

    I had the same problem opening a project, that was created with Xcode 4.0.2, with Xcode 4.1. I simply solved by clicking on "Modernize Project" (Editor/Modernize Project). This procedure automatically removed all duplicates.

    0 讨论(0)
  • 2020-11-30 03:42

    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.

    0 讨论(0)
提交回复
热议问题