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

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!

Related

xcode - linker command failed with exit code 1 - build settings

I'm using Xcode 7 and can't build successfully because of the following error:
ld: framework not found Pods
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The error above is associated with the following file:
Ld /Users/(USERNAME)/Library/Developer/Xcode/DerivedData/(PRODUCT NAME)-(RANDOM STRING)/Build/Intermediates/(PRODUCT NAME).build/USDev-iphonesimulator/(COMPANY NAME).build/Objects-normal/i386/(COMPANY NAME) normal i386
cd /Users/(USERNAME)/Developer/(PRODUCT NAME)-ios
export IPHONEOS_DEPLOYMENT_TARGET=8.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
This error started occurring after merging multiple branches of code (each branch worked properly prior to the merge). Can somebody tell me what is causing this error and how I can get past this problem?
----- UPDATE -----
Spending more time on this problem, I've noticed that the merged code works on my coworkers computers so the issue must be local. Looking at the "Build Settings" (Go to the workspace file -> Build Settings (middle pane)), I noticed that the settings under the "Linking" section of "Build Settings is different between Xcode on my machine compared to my coworkers. Not sure if this is the root issue, but does anybody know what I need to do in order to set the Linking settings?
There was an extra framework that I needed to remove:
Go to your .xcworkspace file
Click on the "General" tab in the Editor pane
Scroll down to the "Linked Framework and Libraries" section
Find the framework/library that the compiler is complaining about (in my case it was called "framework.Pods"
This problem stumped me for days...

1Password Pods iOS library not found

I resume an project from someone else in my company who make a iOS apps using 1password pods.
i have a build error , i search on the web but i dont found a solution.
maybe can you help me.
here the error :
ld: library not found for -l1PasswordExtension
clang: error: linker command failed with exit code 1 (use -v to see invocation)
thanks in advance
I've run into this problem a few times when using cocoapods. Some of the solutions on this SO post have helped me before Cocoapods ld: library not found for -lPods-Projectname
Also, the official cocoapods site has some help for this issue on their troubleshooting page https://guides.cocoapods.org/using/troubleshooting.html:
If Xcode complains when linking, e.g. Library not found for -lPods, it doesn't detect the implicit dependencies:
Go to Product > Edit Scheme
Click on Build
Add the Pods static library, and make sure it's at the top of the list
Clean and build again
If that doesn't work, verify that the source for the spec you are trying to include has been pulled from GitHub. Do this by looking in /Pods/. If it is empty (it should not be), verify that the ~/.cocoapods/master//.podspec has the correct git hub url in it.
If still doesn't work, check your Xcode build locations settings. Go to Preferences -> Locations -> Derived Data -> Advanced and set build location to "Relative to Workspace".
If all else fails, you can always try deleting the Xcode workspace and the Pods directory, then re-running 'pod install' to see if that clears things up.
Thanks Rob T, i edit the scheme and now it's work.
just before to run i made a pod install.

Compiler error after adding a new Configuration in project

I encountered an issue after setting up a new value for Configuration when building (after reading the following post: Different App Icons for your iOS Beta, Dev, and Release builds). The error message is as follows:
ld: file not found:
/Users/.../Library/Developer/Xcode/DerivedData/SomeAppName-.../Build/Products/Debug-iphoneos/SomeAppName.app/SomeAppName
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
I'm not sure how to fix it, checked and double checked with the article and I did follow everything as explained.
Edit: The error appears to be from the Tests target
Managed to find the answer: https://stackoverflow.com/a/29887473/2124535
I solved it in Xcode 6 very easy like this:
Select your project in the project navigator.
Select the YourProjectTests under targets
Under General tab change the Host Application from the drop down
Build and run.
This problem happened to me because I renamed my project and the tests could't find it anymore. - Yowza7
Removing the Tests target did not help for me.
I posted a solution that did work here: Created new XCode Configuration and Scheme - linker is suddenly failing
It basically involves telling Xcode to look for the libraries created using the Release configuration.

Project upgraded from Xcode 5 to 6 won't compile

I upgraded from Xcode 5 to 6 and now my code won't compile. I found some similar issues from 3 to 4 but none for the newest version.
Here is the error I'm getting.
ld: building for iOS Simulator, but linking against dylib built for MacOSX file '/Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is there a common fix for this?
Thanks for any help.
I had a similar problem which was fixed by running clean (in menu under product/clean).
Edit 1:
Oh found issue with your build settings.
1.
How come the test file is linked with your project?
Just remove the "XCTest.Framework" file from Project Navigator > Targets > 'Project Name' > Build Phases.
Then, "Product" (drop-down) > Clean. Did it for me!
2.
Also
Project > Targets > 'Project Name' > Build Phases > Compile Sources
XCTest should not be included in your regular application code. So you should remove any Test Source from the Compile sources and move to Test Target.
You should update your 'Build active architecture only' to NO in Build Settings.
Restart Xcode and clean build.
Should work fine.
Sounds like you need to remove the XCTest framework from your project file and re-add it from the iOS frameworks.
Seems odd that your iOS project somehow got linked to a Mac framework during the upgrade.

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