Xcode, Duplicate symbol _main

前端 未结 10 826
抹茶落季
抹茶落季 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:27

    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

提交回复
热议问题