Xcode duplicated _main character

I have a duplicate of the _main character.

The problem is that he says: "Duplicate the _main character in /Users/.../i386/main-B9843B6026D6EFA4.o and / Users /.../ i386 / main-B9843B6026D6EFA4.o, XXX and XXX on the in fact the same .o file. I don’t know why he thinks he duplicates the character when he is the same .o ?!

Any thanks, thanks.

+51
xcode
Aug 01 '10 at 6:13
source share
10 answers

Ah..I finds out that I have several entries in the Targets / Compiled Sources section (in the new Xcode under the section "Build Phases / Compilation Sources"). I deleted them and the problem is resolved. The multiplayer thing is probably related to Git merge.

+86
Aug 01 '10 at 6:27
source share

It turned out that in my case, I imported the .m file instead of its .h. Solved by editing

#import "Tools.m" 

at

 #import "Tools.h" 
+23
Oct 10 '12 at 13:19
source share

I also had this problem and it was caused by code that I imported from another project. I made 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[]) 

IMPORTED_DIR contained an additional main.m which caused an error for me

I deleted this file from the project -> Goals -> Build phases -> Compile a list of sources, and then compiled

+15
Aug 27 '12 at 12:24
source share

I ran into the same problem using two third-party frameworks. (AppLovin and Flurry) And I found out that by removing "all_load" from the "Other linker flags" in the build settings.

+6
Nov 21 '14 at 14:24
source share

I had the same problem opening a project that was created with Xcode 4.0.2, with Xcode 4.1. I just decided by clicking on "Upgrade Project" (Editor / Upgrade Project). This procedure automatically deletes all duplicates.

+3
Aug 16 2018-11-11T00:
source share

If there is still a problem, try searching as follows: "int main (" and delete these files except main.m

+2
Dec 01 '11 at 13:33
source share

I had this problem myself, but after reading the huggie solution that led me on the right path, I got a little embarrassed. So, the current solution in Xcode: Select the phases of the project, goals β†’ builds and click "Check Settings"

Then Xcode will automatically fix its error. It is always good when tools try to stop your progress;)

+2
Jun 27 '12 at 7:50
source share

In my case, I declared NSString in a constant file (imported by many classes), but forgot to define it as static.

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

Reading the full error message allowed me to understand this: "Duplicate the PARAMS character". Do not be afraid and do not try to understand the error messages! Sometimes they can even tell you what you did wrong.

+2
Aug 04 '14 at 23:14
source share

You can also get this for method names!

I got a duplicate symbol _runOnMainQueueWithoutDeadlocking after adding DBCamera via CocoaPods, and this is because my category in NSObject (NSObject + Tools.h) and the GPUImageOutput.m dependency file from GPUImage had a method called runOnMainQueueWithoutDeadlocking.

I was fortunate enough to remove my method from the code because I did not use it anymore or anywhere else.

I probably deserve to put a category in NSObject.

0
09 Oct '14 at 0:21
source share

In my case, I imported another project in order to use the library contained inside. As a result, my project had two main.m files.

This was even more confusing since the error did not appear until a few builds later.

0
Oct 28 '14 at 5:22
source share



All Articles