0
votes

I've been new to xCode and facing this issue while adding a new file to existing project. The error I receive is :

duplicate symbol _main in: /Users/jagtapawan/Library/Developer/Xcode/DerivedData/pdf-gowwoupvsiukblehcdbaeublehki/Build/Intermediates/pdf.build/Debug/pdf.build/Objects-normal/x86_64/main.o /Users/jagtapawan/Library/Developer/Xcode/DerivedData/pdf-gowwoupvsiukblehcdbaeublehki/Build/Intermediates/pdf.build/Debug/pdf.build/Objects-normal/x86_64/func.o ld: 1 duplicate symbol for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

what I do is File -> New -> File. on the left panel select iOS source -> objective c -> next. It insists me to to enter

File: func

File type : Empty

Class : NSObject

my file hierarchy in Xcode is this way :

pdf

-func.m

--pdf

----main.m

--products

----pdf

whereas in finder the func.m and main.m are in the same folder pdf. please help me

1
Welcome to Stack Overflow! Do you have a main() function in both func.m and main.m? You should only have one in main.m.Eric Galluzzo
What does the code in func.m look like?Phillip Mills
@EricGalluzzo ,Yeah , I've main() function in func.m and main.m. I wan't to run both files independently... just like it happens in java.How do I achieve it? Please helpJagtaPawan
@PhillipMills it consisted of simple swap program using a swap function and a main function which called the swap function.But when I faced issues in executing it, I just included simple "NSLog(@"Hi"); "... :P still it persists. Please help.JagtaPawan
You can't have two main functions linked together in the same program. To run two different "mains", you need two programs.Phillip Mills

1 Answers

0
votes

I was able to solve the same problem with the following code.

Add this to the Library Search Paths in Build Settings and make sure you select recursive, delete other library paths which might be absolute paths.

$(PROJECT_DIR) 

May be it will help you.

OR

You have duplicate symbol method which means there are duplicate file in project

In your Target's Build Phase, under "Compile Sources" check if there are duplicate file and delete one if you have duplication.

Hope this will help you.