Mach-O Linker Error on Xcode 4.6
Asked Answered
B

10

16

I have an iOS app on Xcode 4.6 and when I recently tried to build and run in the iPhone 6.1 simulator I got a "Mach-O Linker Error." It continued to say:

ld: 17 duplicate symbols for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Does anyone know how to solve this?

Thanks so much!

Body answered 20/2, 2013 at 21:52 Comment(5)
https://mcmap.net/q/747476/-duplicate-symbol-errorStation
Hi flexaddicted, I apologize but I am confused which one is the solution in that link. I looked at the first solution about the mistake with the import statements and I checked and nothing was wrong with that. Is there something else I should be looking at? Thanks.Body
It's possible you've defined some variables in a header file somewhere that's been included a few times. Can you give us more information about the duplicate symbols?Federalist
Forgive me as I am not very good with code (I've created this app using buzztouch.com). I searched for "architecture i386" and found it in a sample.js file where it says " "warning: no rule to process file '$(PROJECT_DIR)/sample.js' of type sourcecode.javascript for architecture i386"" That's the only place it's at. Please let me know if you need anything else. Thank you so much.Body
Check if you have added the same files twice in project.Hutch
A
23

Just go to "Build Phases" -> "Compile Sources" and look for duplicate of classes.

Apodal answered 20/2, 2013 at 22:32 Comment(1)
Hello edzio27, I went to the "Compile Sources" sections and could not find any duplicate classes. Is it definitely a duplicate class there because I checked several times and could not find anything. Thanks so much.Body
T
17

Check if you have "*.m" files in your #import ! It appears that was my mistake...

Tasiatasiana answered 22/8, 2013 at 14:55 Comment(0)
B
7
  1. Quit Xcode
  2. Restart the System
  3. Select Xcode -> Preferences -> Locations
  4. In Locations, you will see 'Derived Data'. Click on the arrow icon right next to the path.
  5. This will open a folder containing 'Derived Data', delete it.
  6. Clean the Product and Run

    if still not works then

    Build Settings > Enable Bitcode > No enter image description here

Bookout answered 5/7, 2017 at 7:39 Comment(0)
N
5

In my example, I declared

extern NSString const *keyString

in two different files. I renamed one of them and it solved my problem.

Norty answered 15/7, 2013 at 23:11 Comment(0)
T
2

In my case it was constants.

NSString *const cellID = @"cellID";

This line was written in two .m files. After appending static keyword at the start the problem was resolved.

This issue can be recreated in a new project too. You would think that defining constants in the different .m files won't have any effect as they are private. But I don't know how the compiler is handling stuffs behind the scene. On top of that when you tap the issue from issue navigator it doesn't open up a page in the editor like it does for any other issue. Really frustrating.

Throstle answered 3/4, 2017 at 5:42 Comment(0)
L
0

I am not sure I can give you a solution but I will share an answer since the same happened to me on xCode 4.6 as well. I added a C class header and implementation file and included them in main. I then decided to delete that new C Class header and implementation. When I ended up adding a new c class/header again with the same name and function calls, I ended up with your error.

Frankly, this might be a bug. The only and fastest way I fixed it was to start a new project and pull all the classes in.

Lanoralanose answered 21/2, 2013 at 0:43 Comment(1)
You should normally be able to delete the files in the finder and even inside the Projekt Navigator and create again a new class.Jujube
G
0

Make sure you don't have non-instant methods with the same name in multiple classes (So for example if I have two viewcontrollers that are pretty similar so to move quickly I copy and paste the code from one viewcontroller to the second and they both have methods called the same thing like: NSMutableString *filteredStringFromStringWithFilter(NSString *string, NSString *filter)) then the app gets confused which of those methods to use since they are both available, RENAME IT on the second class and change any calls to that method on that class and you've removed the confusion. Don't we all want things to be more clear!

Googins answered 19/9, 2013 at 16:16 Comment(0)
R
0

If you want to change a value both in tow different class. Do remember to mark with static keywords.

or the clang will throw such error below without any value interpretation。

Apple Mach-O Linker Error clang: error: linker command failed with exit code 1

Ruy answered 14/4, 2017 at 4:17 Comment(0)
M
0

When you refactor a class func you will also sometimes get this error. Just go to Product-> Clean and rebuild.

Mealie answered 17/5, 2017 at 17:39 Comment(0)
S
-1

Build Phases" -> "Compile Sources" click the button "Validate Settings"

it's will fix your project

Spindry answered 11/9, 2013 at 2:21 Comment(2)
Where is this button?Sacral
couldn't find it !? are you serious about it ?Scoundrel

© 2022 - 2024 — McMap. All rights reserved.