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

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

Related

Xcode project giving pod file error for FIRAnalyticsConnector.framework . How to solve it?

I'm working on a book project and the project is connected by API . I'm working on the book app which has different libraries imported from the various places.
Recently, i cloned the project from bitbucket in Xcode and tried to run it. The result i got i error as follows:
enter image description here
It shows :
ld: in /Users/ishinfoservices/Documents/vadltaldhambooks/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRAnalyticsConnector_a8eeba373b74508311b8b22b8d3202a6.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/ishinfoservices/Documents/vadltaldhambooks/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Help needed to fix the error, as the project has lots of mixes of old libraries along with .h and .m files, the swift files with wireframes
According to the image I saw that you are trying run the app on the iOS simulator, then you could try to add the arm64 to the Excluded Architectures on the Build Settings section of your project or target, it would be like:
Take in mind that if you use Cocoa Pods is possible that also you should add the arm64 to the Exclude Architectures into the Pods project
After the above, clean, build and run the project on the iOS simulator, is possible that on your physical device you must remove the arm64 from the Exclude Architectures, it could depend on what you use in your project.
On the other hand, you can try the following: Select the project -> Select the target -> Go to the Build Phases -> Expand the Link Binary with libraries and add all pod libraries (remove if they exist in embedded binaries or Remove the old FrameWorks), after that, clean and build the project

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...

How to use Realm (installed with Carthage) with a framework in a Swift app?

I'm working on an iOS App and a Watchkit App.
I read a few things regarding best practices and I decided to create a custom framework, as NathashaTheRobot advise here:
https://realm.io/news/architecting-app-apple-watch-natashatherobot/
So I'm trying to use Realm in my framework.
I followed the installation instructions for Carthage:
Add github "realm/realm-cocoa" to your Cartfile.
Run carthage update.
Drag RealmSwift.framework and Realm.framework from the
Carthage/Build/iOS/ directory to the “Linked Frameworks and
Libraries” section of your Xcode project’s “General” settings.
On your application targets’ “Build Phases” settings tab, click the
“+” icon and choose “New Run Script Phase”. Create a Run Script with
the following contents:
/usr/local/bin/carthage copy-frameworks
and add the paths to the frameworks you want to use under “Input
Files”, e.g.:
$(SRCROOT)/Carthage/Build/iOS/Realm.framework
$(SRCROOT)/Carthage/Build/iOS/RealmSwift.framework
Then I added my framework to the Target Membership of both Realm.framework and RealmSwift.framework.
But when I try to build the project, I get this error:
ld: framework not found Realm for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Then I gave a shot to lipo:
$ lipo -info Carthage/Build/iOS/Realm.framework/Realm
Architectures in the fat file: Carthage/Build/iOS/Realm.framework/Realm are: i386 x86_64 armv7 arm64
Do you have any ideas of what I might be doing wrong here? Thank you.
EDIT:
OK so I found the problem and it was totally unrelated to Realm...
It looks like I deleted the Headers and Resources sections of my framework Build Phases somehow (which were and are still empty). I just put them back and everything compiles/works like it should.
Don't be tempted to delete those two
Is it possible that it's your test target that can't find the frameworks? You'll have to add the parent location of the frameworks to the "Frameworks Search Path" section of your unit tests (likely $(SRCROOT)/Carthage/Build/iOS).
Here's a sample project of a Swift framework bundling RealmSwift as a dependency which you might find useful to compare your build settings against: https://static.realm.io/debug/ParentFramework.tgz

Apple LLVM Compiler 4.2 Error : NO such file or directory

I get a error from the Xcode as below:
clang: error: no such file or directory: '/Users/Ashok/Desktop/projectdir/AScommon/View Support/GradientView.m'
clang: error: no input files
Command
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
The main thing is that file/directory path shown above doesnot exists in my mac.
Have tried with the following:
I even set the paths in the Build setting search paths.
I have tried all the methods of cleaning the project,
reopening of the xcode, clearing the derived data.
Can anybody please guide me the solutions, so the app will built without errors.
Thanks in advance.
Sometimes it happens like this.May GradientView.m exists in your target location, just check whether it is available in your project and its color should not be red. If it is red then select that file and delete that file.And again add it by Right click on your project > Add files to "Your project" > add again GradientView.m file. Then Product > clean and built > run.
The problem might be because your project > target > Build Phases > Compile Sources is trying to compile a file that doesn't exist. Please check if GradientView.m exists according to above step.

linker command failed in Xcode

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. : - )

Resources