Apple Mach-O Link - ios

I got an error while compiling my code. The issue identifier labels it as 'Apple Mach-O Link Linker command failed'. I have no clue what this is so I have not been able to find a solution.
duplicate symbol _OBJC_METACLASS_$_XYZFlipsideViewController in:
/Users/studentuse/Library/Developer/Xcode/DerivedData/RSC-
aardgrngtzicssfffcbdqsezpqmv/Build/Intermediates/RSC.build/Debug-
iphonesimulator/RSC.build/Objects-normal/i386/XYZAppDelegate.o
/Users/studentuse/Library/Developer/Xcode/DerivedData/RSC-
aardgrngtzicssfffcbdqsezpqmv/Build/Intermediates/RSC.build/Debug-
iphonesimulator/RSC.build/Objects-normal/i386/XYZFlipsideViewController.o
ld: 6 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation) //This
line has the mistake
What is the problem with the code?
(This is only part of the code.)

The problem is that you have defined the implementation of the class XYZFlipsideViewController twice, and the linker can't figure out which definition you meant:
duplicate symbol _OBJC_METACLASS_$_XYZFlipsideViewController
The two places it is defined in are these two object files:
XYZAppDelegate.o
XYZFlipsideViewController.o
There are two possible explanations:
You have a #implementation XYZFlipsideViewController ... #end block in both of the source files XYZAppDelegate.m and XYZFlipsideViewController.m, or
You have the #implementation ... #end block inside a header file which is #include/#imported by both of those source files
In the first case, the solution is to remove one of the #implementation blocks. In the second case, the solution is to move the #implementation block from the header into the source file, but keep the #interface block in the header file.
It's important to understand the distinction between #interface and #implementation -- the former says "Here is the name of a class, the names of its instance variables, and the names of its member functions", whereas the latter says "Here are all the definitions of the class's properties and member functions".

Make sure and check your actual project directory for multiple files of the file it says you have duplicates of. Sometimes I forget to click send To trash vs remove reference when deleting and re creating files.
I am not sure this is your problem, but I have had similar problems like this before.
Good Luck! ^^

Related

Xcode not generating correct coredata model files

Im generating my core data model after changing my models files using Editor -> Create NSManagedObj...
I changed an entity relationship to a different entity (if this matters)
Iv cleaned my project and build folder.
But the generated files don't seem to be correct, they include files such as 'Entity.h'
Which doesn't exist... As the only class files i see are 'Entity+CoreDataClass.h'
So i change the name manually to the all above errors and then i get a linker error:
duplicate symbol _OBJC_CLASS_$_Userinfo in:
/Users/Me/Library/Developer/Xcode/DerivedData/test-fxdxcviituhcmoegqygwirddhuir/Build/Intermediates/test.build/Debug-iphonesimulator/test.build/Objects-normal/x86_64/Userinfo+CoreDataClass.o
duplicate symbol _OBJC_METACLASS_$_Userinfo in:
/Users/Me/Library/Developer/Xcode/DerivedData/test-fxdxcviituhcmoegqygwirddhuir/Build/Intermediates/test/Debug-iphonesimulator/test/Objects-normal/x86_64/Userinfo+CoreDataClass.o
ld: 2 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Originally i created the project using an older version of Xcode, where the entity files such as 'Entity.h" were generated... Is this some sort of bug with Xcode after updating?
My entities are using the 'manual/none' codegen option. But i notice after building that the entity with the above linker error automatically changes to 'Class Definition'?
EDIT:
Ok so setting the codegen to class definition to all entities stops the wrong file import errors. (but then still revert back to 'manual/none' afterwards. Except for my newly created entity.
Where there is the error in the derriveddata for the +CoreDataClass.m file... where it does not include the +CoreDataClass in the import name.
My +CoreDataClass.m file within my project does not include this error and is correct with the +CoreDataClass.
My project generated file:
#import "Userinfo+CoreDataClass.h"
#import "User+CoreDataClass.h"
#implementation Userinfo
#end
Where the error exists: (in derived sources)
#import "Userinfo+CoreDataClass.h"
#import "User.h"
#implementation Userinfo
#end
Try to click on project. Next click the "Show version editor" (the top right button on the picture) button and try to find duplicated references and remove it.
Should solve the problem
I think I found the answer, in your xcddatamodel file after choosing your entity. On the right panel, you will see a "Code Generation" DropDown. It might default to Swift, change it to Objective c and build the project. Your file will be generated.

Objective C : linker command failed with exit code 1

This is the error I'm getting when I try to build my app.
ld: 10 duplicate symbols for architecture arm64
From the error, I would guess that:
you have two files, VaultSelectionViewController.m and SetLockViewController.m (the first being originally a copy of the second, probably)
they both contain #implementation SetLockViewController, and identical properties and/or methods and/or instance variables.
Solution: fix the class name in the #implementation to match the file name.
If that's not the issue, please provide the relevant parts of both files.
Your project twice referring to file SetLockViewController.m.
My suggestion is take a copy of class out side of your project.
[1] Then right click on SetLockViewController.m file and delete > move to trash.
[2] Go to project files directory in finder. Then delete the file SetLockViewController.m (if you find any).
[3] Clean the build and run.
Follow same method if any other duplicate files/linker errors present.
Make sure your compile sources does not have dup files. (Bad merge can cause this issue.) Remove them and add them again can fix this build error.
Make sure you does not implement one function twice. (Copy codes and forget to rename the #implement XXX? Or copy and paste one function twice?) Just search the function define in your project and remove the dup one.
Please check all the variables name in every classes of your project and make sure that all they have unique name including outside the class

Getting Linker Errors since I tried to implement a new m-file

I just started working with xCode and Objective C.
I created a project with an storyboard and implemented my entire program into the view-Controller. I wanted to put some of this code now into a different m-file wich I simply include and call methods from my new m-file in the view controller.
My problem is that I get not linker-errors every time I try to build it.
The error code is
1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
What could cause this?
This error is due to you have a duplicate symbol somewhere. Check this link this will helpful for you
http://iphonedevsdk.com/forum/iphone-sdk-development/115858-apple-mach-o-linker-error.html
You can't have multiple .m files for one .h file. You need to either:
Keep all the code in the original .m file.
Create a new class with it's own .h file.
Create a category for the original class.
(https://developer.apple.com/library/mac/documentation/cocoa/conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html)
Make sure you only have one #interface and one #implementation declaration for each class.
I found my problem.
I happened to implement the same variable as global in two m-files.

Category Conflict: instance method in category from conflicts with same method from another category

There are two situations, that I am aware of, that cause the following errors:
ld: warning: instance method 'resetAudioSystem' in category from /opentok-ios-sdk/Opentok.framework/Opentok(OTPublisher+AudioSnoop.o) conflicts with same method from another category
ld: warning: instance method 'attachAudioSnoopBlock:' in category from /opentok-ios-sdk/Opentok.framework/Opentok(OTPublisher+AudioSnoop.o) conflicts with same method from another category
ld: warning: instance method 'setVideoSnoopDelegate:' in category from /opentok-ios-sdk/Opentok.framework/Opentok(OTPublisher+VideoSnoop.o) conflicts with same method from another category
Possibility 1: A category instance method is declared twice. (Described here: SO)
But, When I do a search of any of the 3 instance methods (in Xcode or Grep) I do not find it declared twice.
Possibility 2: Accidentally importing a .m file. (Described here: SO)
But, I checked all my imports and I only import the framework once in the whole project. Also, only shows up once in Build Phases.
My program runs without crashing, presumably because the last category definition added is used and it happens to be correct. (Source)
Question 1: Is there a way to tell, prior to its addition, where the two categories are located?
Question 2: Any other ideas about how to resolve this?
Note: The Opentok Framework is a binary
Occurs in :
xcode 4.6 & xcode 5
iOS6 & iOS7
I had this warnings because I accidentally imported the implementation file of a category instead of it's header file. So:
wrong: #import 'MyClass+MyCategory.m'
right: #import 'MyClass+MyCategory.h'
I had this error, because I literally pasted my methods' implementation to header file (*.h). It worked well however; the only symptom - warnings.
Check whether your implementation is in correct (*.m) file.
This look like a linker bug. Maybe the SDK got linked more than once, or -ObjC is missing/present where it should not be. Check linker flags. Try deleting all OpenTok frameworks, make sure its missing in your projects, then re-download it and install again.
In my case the header file containing the categories was imported twice for a class.
It wasn't obvious because another header file also imported the same header.
In other words
//Class_with_warnings.h:
#import "Offending_Header.h" // import #1
#import "Class_A.h" // import #2
//Whereas Class_A.h:
#import "Offending_Header.h" // import #2

Duplicate Symbol Error in Objective-C build?

I got this error when I press build+debug:
ld: duplicate symbol .objc_class_name_BlogTableItemCell in /Users/fabian/Development/Workspaces/iphone_experiments/xcode_build_output/MausLog.build/Debug-iphonesimulator/MausLog.build/Objects-normal/i386/BlogTableItemCell-3733583914888A7B.o and /Users/fabian/Development/Workspaces/iphone_experiments/xcode_build_output/MausLog.build/Debug-iphonesimulator/MausLog.build/Objects-normal/i386/BlogTableItemCell-3733583914888A7B.o
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 failed with exit code 1
You could also get this error if you mistakenly let Xcode's auto-complete for #import statements specify the '.m" file for the 'duplicate' class instead of the '.h'.
It seems that you are compiling the same BlogTableItemCell class two times in different places of your code. This may happen in the following cases.
You have put the same class
implementation into two different
files;
You actually have just one
implementation of this class, however
you are also linking in your project a framework
or library containing a class whose
name is exactly the same of yours.
Try finding in the whole project your class and make sure only one copy is available within your project.
For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation )
I had a similar problem due to poor defining of consts.
I had defined a const in my header:
int const kCropLocationTop = 1;
This was presumably imported multiple times. To fix i changed the header def as follows:
extern int const kCropLocationTop;
and moved the assigning of the const to the .m file:
int const kCropLocationTop = 1;
Hope that helps anyone who's as ignorant of simple objective c concepts as I am!
iPhone: Duplicate Symbol Error? by user576924
answered it correctly for me. However to find the offending gremlin this ZSH snippet.
grep "import.*\.m" **/*.[hm]
Will immediately tell you where your error is.
By mistake the source file was included twice in the Project -> Build Phase -> Compile Sources. Removing one of them solved the problem.
The most common reason for this error is importing an xyz.m file instead of the xyz.h file.
Check if your imports contain something like
#import "----.m"
Just to add; Using Xcode to generate subclassed managed objects (Core Data) can sometimes duplicate the generated files. For me the fix was to delete the generated files and re-generate them.
I just ran into this problem myself. For the list, here's another possibility:
Duplicated linking line in the project file.
I caused this merging conflicts on a SVN update, when I accidentally duplicated a line.
It happened to me, too. In my case, one (just one) of my core data automatically generated classes was inserted twice. I spotted the duplication by looking at Build Phases...Compile Sources. Simply deleting one of the occurrences solved the problem.
Adding another possible cause to the list... you may have mistakingly created multiple constants in the implementation file, but outside of the implementation, with the same name.
In HeaderFileOne.m
NSString * const kCoolConstant = #"cool";
In HeaderFileTwo.m
NSString * const kCoolConstant = #"cool";
So changing one of those constant names would fix the compile error.
This may help someone
I got this error because I duplicate a ViewController and then renamed it. So when I compile I got this error. The reason was in both of the view controllers there was a "float" variable with same name i.e "float padding=10.0" which I had defined on class level.
Renaming the name of the above mentioned variable in One of the view controllers solved my problem.
I also faced to this problem. My solution was rename one of global variable, which has the same name as one in other class. Hope this helps
The same thing happened to me while I was playing with localizable xib files, accidentally I have created two implementation files and appereantly that caused the problem in my case. After deleting / recreating the implementation file without doing the same mistake, the error was fixed.
One of our developers left the "libSoomla*" project files in there twice. I removed the duplicate soomla files, re-built, and that fixed it!
Hope it helps.
In may case, I followed some instructions to build a newer version of Subversion which directed me to create this symbolic link:
ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain
Now I'm really a Windows guy so it wasn't immediately obvious to me - but removing the link fixed it for me (after restarting XCode):
rm /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain
Phew.
(The actual error I got was the one described here:
build error duplicate symbols arclite.o)
Make sure that you didn't import .m File . For me this happen I added #import "SchoolCommuterHome.m" instead of #import "SchoolCommuterHome.h"

Resources