linker command failed in Xcode - ios

I was building an app, but later on I quickly changed something(a value in char variable) and tried to load again, now I am getting this error
ld: 9 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have undone what I have done, but still I am getting this error.
I have tried to delete build folder, it did not work... I also performed clean and build but still it cannot build...

You have to check the files included in the build. Quite possibly there are some duplicate implementation (or perhaps header?) files included.
Navigate to {Project} > {Target} > Build Phases.
Check the Compile Sources build phase for duplicates.
Remove all duplicate files.
Also make sure no duplicate libraries are included in the project. You may check this in the Link Binary With Library phase. Basically same story as above, but for libraries.
Finally make sure to clean the project before building (Product > Clean).

My error message was a little different - duplicate symbols ... in ClassImplmentationFile.m
I didn't have any of the duplicates, as described above, but I noticed that the .m files that were listed in the error message, were in Build Phases/ Compile Sources.
I removed them from there and the thing ran fine.
I didn't put them in there. I guess Xcode auto-screwed-up my project at some point. : - )

Related

Xcode 7 simulator error "duplicate symbols for architecture x86_64"

My development environment with Xcode 7.2.1, CocoaPods 1.0.0 and GoogleMaps 1.13.2
I can build code successful to generate a XXX.ipa file and install in my iPhone 6 Plus to work correctly.
But when I run Xcode simulator by item "iPhone 6" or "iPhone 6 Plus" always get the information as below
"xxxx duplicate symbols for architecture x86_64" "linker command
failed with exit code 1 (use -v to see invocation)"
I use the following solutions still can't fix it
Build Options -> Enable Bitcode -> set "No"
Remove -ObjC from Other Linker Flags
project Targer -> Build phases -> compile sources, ckeck no duplicate files
Make sure I haven't #imported a .m file
I am wondering if there are any other method to solve this, help would be appreciated thanks.
This error generally occurs when you have linked any library or file twice.
In the error desciption, the name of the duplicated file will be listed, you can search and and make sure you don't have duplicates.
If you find duplicates, remove reference to one of them to play safe
I have faced similar kind of issue.
In my application I have run my code and created ipa before two day. And today when I am trying to run same code without any changes I am getting:
ld: 102 duplicate symbols for architecture x86_64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
The solution for this duplication Linker error can be solved by Remove all of your classes from compile sources, then click the + button and search for the term '.m'. Highlight every class, then click add. Build and run again.
This problem can also be occurred in case you import ".m" file instead of ".h" by mistake. I know it may be seemed as a stupid advise but this is what I had done in my case.
I resolved this issue by removing the -all_load flag in the Build Settings-> Other Linker flags.

Command [...]/clang failed with exit code 1

I have a serious problem with one of my ios application because i can't compile it anymore. I think its due to a mislinked file (see the error at the end).
The whole story started when i wasn't able to add a file to a target. I then couldn't build because of this error, see: Duplicate interface declaration for class 'Foo'. Xcode miracously copied my sources within itself to a subfolder with the projectname. I deleted as suggested but i know keep running into the error pasted at the bottom.
In effect it is due to clang looking for a file a very deeeeeeeply in itself nested folder which of course doesn't exists. What did xcode do here and how can i get it working again?
This is the last part of the error
clang: error: no such file or directory: '/Users/Shared/projects/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/samefolder/AppDelegate.m'
clang: error: no input files
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
Okay i found it! I knew there had to be a list of files it tries to compile somewhere. I finally found it under the targets build phases. There you have entries for "compile sources" and "copy bundle resources" which both got cluttered in my case. I corrected those file lists and it finally worked again.

Debug scheme won't build - Apple Mach-O Linker Error. Linker command failed with exit code 1

ld: library not found for -lPods-AFNetworking
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I get this error way too often and it's driving me (and the team nuts). The project was building just fine last week and I did nothing to the project in the mean time, just opened it yesterday and now I'm getting this error when building using the Debug scheme only; Adhoc builds fine. I'm running the latest Yosemite, Xcode 6.1 (but this has plagued me for many months anyway). My instructions to resolve it work occasionally, like black magic:
Clean
Restart Xcode
Delete derived data (check preferences/locations)
Pod update
Open project using the Workspace file
Delete the workspace file and run pod install
But unfortunately this time it's just not working! I've done this process over and over. I'm so frustrated with this PoS Xcode. Next step would be to re-download the project from Git, but there must be a better way! I have gone through a number of other stack overflow posts but found nothing to help (nor anything very recent). Thanks!
The same error drove me nuts for two days. I fixed through the following :
Project > Targets > Build Settings > Packaging > Product Name - Check if the product name has changed.
Also try setting the Build Active Architecture to NO in your project..
Project/Pods > Build Settings > Architectures > Build Active Architecture Only
Just delete the build folder of your project and rebuild it again. Always works for me!

Build failing? Apple Mach-o linker error?

My app was working fine until I started playing with archiving. Im not getting any compiler warnings or errors, but when I run the app, the build fails, saying
Apple Mach-o linker error: linker command failed with exit code 1 (use -v to see invocation)
I commented out all the archiving code I was playing with, but the build continues to fail, and I have no idea why. Again theres no warning/errors until I build, so I don't know what happened or where its coming from?
Can anyone tell me what this means and what I need to do to fix it?
EDIT:
Here is what the issue navigator says:
/Users/MikeGordon/Library/Developer/Xcode/DerivedData/HW1ARC-egqtecfuosawiadlwgfulhqjdhtr/Build/Intermediates/HW1ARC.build/Debug-iphonesimulator/HW1ARC.build/Objects-normal/i386/Assignment.o
ld: 18 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: 18 duplicate symbols for architecture i386
EDIT: Here are some screen shots
http://imgur.com/3zd53ZP
http://imgur.com/tqhCa1g
http://imgur.com/Ena17FF
Check that there are no duplicates under Targets/Compiled sources. If there are duplicates, delete them.
I don't know how, but many of my .m/.h files were duplicated and under other folders. To remedy the problem, I deleted one copy of the file from one of the folders. The other duplicate file, then turned red. So, then I deleted the second copy of the file. At that point, I had no instances of either file in xCode. Then I went to my Trash, sorted by Date Added, highlighted the files that were just placed in Trash, right clicked and selected Put Back. The I went to File> Add Files to ("myProject") and selected the files I just restored. Everything was back to normal at that point. I ran the simulator and it all worked great!
Peculiarly, the Trash only had one instance of the file, even though it was referenced twice in the Project Navigator.

clang: error: linker command failed with exit code 1, only when testing on device

I was just about to test my app on a device when I ran into this problem, I'm getting this Linker Error.
I've already checked all my compile sources and Build Phases, but there's no sign of my importing things twice.
ld: duplicate symbol _calculateNextSearchPage in /Users/wouter/Sites/test/FastPdfKit.embeddedframework/FastPdfKit.framework/FastPdfKit(FastPdfKit) and /Users/wouter/Sites/test/FastPdfKit.embeddedframework/FastPdfKit.framework/FastPdfKit(FastPdfKit) for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This only happens when testing on a device, not in the simulator.
Alright guys I had the same problem. Seems like I fixed it.
I am using cocapods therefor the described standard procedure can not be properly executed.
Steps to do to properly add FastPDFKit with Cocoapods.
Download FastPDFKit
In your project Add Files to "Your Project"
go to FastPDFKit folder you just have downloaded
locate 1 folder and 1 project file. Press and hold Command key and add these in to your project
FastPdfKit.xcodeproj
FastPdfKit.embeddedframework
(Note: FastPdfKit.embeddedframework is the actual Framework and you
might want to open FastPdfKit.xcodeproj standalone before adding it
to your project, delete FastPdfKit.embeddedframework folder from
your disk and Build FastPdfKit target in the project. You should see
newly created FastPdfKit.embeddedframework folder)
Go to your Project Settings > Your target > Build Phases > Link Binary with Libraries
Make sure FastPdfKit.framework is there.
If not, drag it from the project and put it there.
Clean the project, delete derived data
Add #import <FastPdfKit/FastPdfKit.h> where you need it and you are good to go.
Here is how my Link Binary with Libraries look like
Please let me know if you have any troubles I might've missed something.
Try to delete duplicate files/images which are in target-> Build phase -> Compile files, Copy bundle resources

Resources