Linker Command failed with exit code 1 (use -v to see invocation), Xcode 8, Swift 3

IosObjective CXcodeXcode8Carthage

Ios Problem Overview


I can't get rid of this error!

I have tried all sorts of things like clearing Derived Data(Preferences->Locations->click gray arrow to open Derived Data folder in Finder->right-click, move to trash), cleaning the project(CMD+Shift+K or Product->Clean), updating carthage and dependencies, checked other answers on StackOverflow (mostly adjustments in Build Settings/Phases), and recloned the app from github, etc.

The same project works on my collaborators computers..

EDIT: From the current top-rated answer, I was able to debug a little further...I am still not sure how to fix though. It looks like I have something in the project twice? I looked and can't find anything showing up twice!

Here's a picture of the log:

Ios Solutions


Solution 1 - Ios

i was facing same issue today in xcode 8 version 8.3.2

right click on issue --> reveal in log

enter image description here

then you are able to check what is causing that issue

enter image description here

Solution 2 - Ios

Maybe you installed a pod file and you are still trying to build from the .xcodeproj file instead of .xcworkspace

Solution 3 - Ios

the only thing that worked for me was to run pod deintegrate and pod install

Solution 4 - Ios

did you try a clean? cmd + shift + k

Solution 5 - Ios

Okay...So here is what solved my problem...

in App Delegate File:

#import "AppDelegate.h"
#import "DarkSkyAPI.h"
//#import "Credentials.h"

I had imported Credentials.h already in the DarkSkyAPI.m file in my project. Commenting out the extra import made the error go away!

Some things to mention and maybe help anyone in the future. @umairqureshi_6's answer did help me along the process, but did not solve it. He led to where I was able to dig out the info. I kept seeing AppDelegate and DarkSkyAPI files showing up in the error log and the information it was pulling from Credentials file was causing the error. I knew it had to be in one of these 3 files, so I immediately checked imports, because I remembered hearing that the .h carries all the imports from its .m file. Boom!

Solution 6 - Ios

I k now the question has already been answered. But if this helps somebody save some time : I had the same error. I checked everything to find a very small and stupid mistake from my side. I imported a core data ManagedObject custom file in a view controller of my project. I accidentally imported the .m file instead of the .h file which was causing the duplicate symbol in architecture error (linker command failed) because my .m file of properties class imports the .h file of core data class and hence causing duplicate import.

So just check if u have imported the right files before you try multiple solutions.!

Solution 7 - Ios

A lot of solutions are mentioned above. No one worked for me(but please try above first).

Select Project -> Select Target -> Linked Framework and Libraries -> Add all pod libraries . (remove if they exist in embedded binaries)

Now remove these from Framework Folder in left file explorer of xcode.

This solved my issue.

Solution 8 - Ios

Select the project-> Build Phase->Link Binary with libraries and add all pod libraries.

Solution 9 - Ios

I had the same problem using Carthage for dependencies.

Just go to Select Project -> Build Settings -> Search for Enable Bitcode -> If it is selected to Yes, select No.

That solved this problem for me.

Solution 10 - Ios

In my case the reason of the error is library which was linked two times.

I use react-native so it was linked automatically using react-native link and manually in xcode.

Solution 11 - Ios

I had same problem.

The cause was that I declared same global variable in 2 files. So it was showing same error saying 2 duplicate symbols.

The solution was to remove those variables.

Solution 12 - Ios

For any one having this issue with Flurry framework. This is what fixed my issue. For me the issue was that i had imported the following files but never used them. "libFlurryTVOS_9.2.3" "libFlurryWatch_9.2.3"

So all I had to do was go to project target settings and remove these 2 files from the "Linked framework and libraries" section and the problem was solved.

Solution 13 - Ios

Make sure the Find Implicit Dependencies checkbox is checked.

(Product -> Scheme -> Edit Scheme -> Build -> Find Implicit Dependencies)

Solution 14 - Ios

I was testing the Sparkle framework with CocoaPods.

Sadly, I put pod 'Sparkle', '~> 1.21' in the PodFile in the wrong place. I put it underneath Testing (for unit tests).

Once placed in correct spot in PodFile, everything's fine.

Solution 15 - Ios

I just had to do import Foundation!

I was using Kitura for Swift server side and kept forgetting this!

Solution 16 - Ios

Here is my problem and solution:

I removed two files from the source code using source tree(Version controller). After applying the diff, that contains the two classes I removed, Xcode didn't add it automatically. So I got linker error.

I manually added the files, by right click on group name and select "Add files to ". Now my error got resolved.

If anyone faced the linker error regarding class file, then try to add it manually.

Solution 17 - Ios

Did not have this problem when I built and ran on my own device. Only had this problem with simulators. I just simply restarted my computer and ran it. It worked.

Solution 18 - Ios

In my case I have change the Target name in my Podfile So it's create the same Error for me.

> Solution

Just go project-> Build Phase->Link Binary with libraries Remove the old FrameWorks by click on minus button(-) And clean and Run again. It's work me.

enter image description here

Remove Unwanted .framework.

Solution 19 - Ios

The other answers didn't work for me so here I share my solution in case it might help somebody else:

My problem was that I was configuring the Podfile of my XCode-Project for the wrong platform. Changing "platform :ios" at the beginning of my Podfile to "platform :macos" worked for me to get rid of the error.

Solution 20 - Ios

I had the same problem. If you are checking out any github project, then instead of using git clone, use git lfs clone, as sometimes, some large files are not properly cloned by using git only. Also, make sure your bitcode is disabled.

Solution 21 - Ios

For me, the gem lock file was specifying an older version of cocoapods than the one I had installed. I had to re-branch and run bundle exec pod install instead of pod install

Solution 22 - Ios

It seems like the issue is different for most of us, and the error message has decent info. In my case, the Deployment Target was set to 10.13 by the export MACOSX_DEPLOYMENT_TARGET=10.13 line, but I was running 10.14. So I had to switch my Deployment Target to 10.14 in General > Deployment Info, in order for the ITLibrary-related symbols to be available again.

cd /Users/foo/src/scrobble/macos/itunes-scrobble
    export MACOSX_DEPLOYMENT_TARGET=10.13

... SNIP ...

Undefined symbols for architecture x86_64:
  "_OBJC_CLASS_$_ITLibMediaItem", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_ITLibPlaylist", referenced from:
      objc-class-ref in AppDelegate.o
  "_OBJC_CLASS_$_ITLibrary", referenced from:
      objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution 23 - Ios

In my case, I was producing multiple products from the same project. For one of the products, the main.m file imported a header file from another folder under the same project. But that file was not included in "Complied Sources" under "Build Phase". This caused a linker error.

After carefully comparing the "Build Phases" settings for a product that could be built successfully, I realized that the .m file of the header needs to be included in the list of "Compiled Source". My issue was resolved after adding that file. Attaching a picture for clarity. The highlighted file had to be added.

enter image description here

Solution 24 - Ios

One of the reasons of this problem might be "Build Active Architecture Only". You need set to true.

Solution 25 - Ios

IOS version in build phases of pod(in xcode) and ios version in pod file should be same (Try with 9.0)

Solution 26 - Ios

Ok, I had the same problem just today and started googling it, when I came across this thread. I haven't finished reading the question when the answer struck my mind: I declared a class with an empty constructor

class MyClass{
    MyClass();

    void func_one(){
    // code
    }

    void func_two(){
    // code
    }

    ~MyClass(){
        cout << "Deleting object" << endl;
     }
};

Then I thought why not terminating (not sure if I'm correct with word selection here, but who cares) the constructor of my class with curly braces ({}). So I did:

class MyClass{
    MyClass(){}

    void func_one(){
    // code
    }

    void func_two(){
    // code
    }

    ~MyClass(){
        cout << "Deleting object" << endl;
     }
};

The problem eliminated, my code started working perfectly.

I know, the good practice is to investigate the issue and find the real cause, but this worked for me.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJake DobsonView Question on Stackoverflow
Solution 1 - Iosumairqureshi_6View Answer on Stackoverflow
Solution 2 - IosAashishView Answer on Stackoverflow
Solution 3 - IosCharles HarringView Answer on Stackoverflow
Solution 4 - IosFrancisco PerezView Answer on Stackoverflow
Solution 5 - IosJake DobsonView Answer on Stackoverflow
Solution 6 - IosPriyankaView Answer on Stackoverflow
Solution 7 - IosAaban Tariq MurtazaView Answer on Stackoverflow
Solution 8 - IosK PrasadView Answer on Stackoverflow
Solution 9 - IosAdri SilvaView Answer on Stackoverflow
Solution 10 - IosStanislav MayorovView Answer on Stackoverflow
Solution 11 - IosAjit A. KenjaleView Answer on Stackoverflow
Solution 12 - IosCedan MisquithView Answer on Stackoverflow
Solution 13 - Iosllama591View Answer on Stackoverflow
Solution 14 - IospdqView Answer on Stackoverflow
Solution 15 - IosmfaaniView Answer on Stackoverflow
Solution 16 - IosSujananthView Answer on Stackoverflow
Solution 17 - IosjamryuView Answer on Stackoverflow
Solution 18 - IosKrunal NagvadiaView Answer on Stackoverflow
Solution 19 - IosVorashyView Answer on Stackoverflow
Solution 20 - IosAman pradhanView Answer on Stackoverflow
Solution 21 - IosJasonView Answer on Stackoverflow
Solution 22 - Iosns.View Answer on Stackoverflow
Solution 23 - IosRaiyanView Answer on Stackoverflow
Solution 24 - IostemirtatorView Answer on Stackoverflow
Solution 25 - IosZaid MunirView Answer on Stackoverflow
Solution 26 - IosMichael GnedkovskiiView Answer on Stackoverflow