138

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:

4
  • stackoverflow.com/questions/44601404/…
    – Naresh
    Commented Mar 2, 2019 at 9:25
  • 1
    why did you accept the top rated answer if it didn't resolve your issue...?
    – benomatis
    Commented Apr 9, 2019 at 9:07
  • @umairqureshi_6's answer is not proper for this question. I can't understand how it can be the accepted answer of this question. It didn't give any hint.
    – SatelBill
    Commented Sep 6, 2021 at 9:12
  • I have faced this same issue but when I updated XCode, it was fixed. Commented Jun 27 at 7:08

30 Answers 30

166

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

7
  • Thanks for that! Here's what I get in the log: imgur.com/vFkNJzZ Commented May 13, 2017 at 20:42
  • 1
    @JakeDobson Can you please tell me how did you solve this? Commented Aug 6, 2017 at 7:57
  • 1
    @GhasemTabatabaei Check my answer below Commented Aug 7, 2017 at 2:49
  • 148
    Why is this the accepted answer? It doesn't actually answer the question, only potentially assist in reaching the solution.
    – Tom Oakley
    Commented Sep 5, 2018 at 10:29
  • 1
    This is not an answer. Commented May 13, 2020 at 18:40
121

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

3
  • 4
    No, I used Carthage for that reason. That's a legitimate answer that could help other people with this same error, though! Commented Sep 7, 2017 at 23:39
  • 1
    I added m$ AppCenter code to an existing project and it needed Pods. No idea what was going on and had been doing it with the .xcodeproj for over a year.. Something this simple! Commented Jun 19, 2018 at 6:10
  • 1
    My fix was somewhat related to this. I had recently upgraded some dependencies and the project now used CocoaPods. Previously I was always working from the project file. I opened the workspace file, which had both my project and Pods in it, and everything worked fine.
    – Rozgonyi
    Commented Feb 5, 2020 at 16:36
41

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

4
  • 1
    The question has been answered. If you see my comment below, I had imported a file that had already been imported into that file. The project was in a race condition trying to reference the file twice. Commented Jul 25, 2017 at 18:39
  • ok yeah it jsut didnt work for me and when i googled it this is what came up, so i thought id try and help someone else...im new to this, should i delete my answer? Commented Jul 26, 2017 at 0:17
  • I guess not since it's already there. I'm sure somebody might find it useful. The app I was using did not use cocoapods. The thing is, this error is very common and gives little information about itself. So many solutions can be found, depending on each project. Commented Jul 26, 2017 at 15:47
  • It saves my day! God bless you! Commented Aug 6, 2020 at 0:21
23

did you try a clean? cmd + shift + k

4
  • 13
    Oh yeah..plenty of times! Commented May 5, 2017 at 2:28
  • That's literally all I get...Clicking on the text does not send me to any extra information or the location of the file where it happened like it does for most errors. Nothing in the console, it doesn't ever get to running the app because of this error.. Commented May 5, 2017 at 2:38
  • FWIW, I encountered this issue recently when building with an SDK and @FranciscoPerez's suggestion did the trick. Definitely recommend it as a first step before you get too deep into debugging.
    – riastrad
    Commented Feb 26, 2019 at 20:03
  • One of the funny things is, after I try all the suggestion in this whole page, it still cant , but then in last, I in xCode => Product => Clean Build Folder (means your answer here) , finally its work !!!!!!!!! build succeeded Commented Dec 27, 2023 at 6:48
13

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!

8

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

1
  • Yes! This one solves it in 2023, confirmed and many thanks! Commented Jul 10, 2023 at 11:59
6

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

1
  • Yes! This was very similar to my problem. I had the same file imported twice in my project. Rather, I imported a "fileA.h" into "fileB.h", but then imported "fileA.h" and "fileB.h" into "fileC.h", or something along those lines...So the app crashes because it does not know which to use. Definitely a good place to have a reminder for others to double check their file imports! Commented Sep 11, 2017 at 14:36
6

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.

0
5

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.

2
  • can you elaborate pls on the fix? Commented Feb 14, 2021 at 11:26
  • @HagaiHarari I don't remember a lot of details. I would try to unlink manually in xcode and check. Commented Feb 14, 2021 at 19:47
4

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.

3

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.

1
  • 2
    why did you remove both and not just one? Commented Apr 10, 2019 at 15:19
2

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.

2

Make sure the Find Implicit Dependencies checkbox is checked.

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

2

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.

1

I just had to do import Foundation!

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

3
  • Ha. Yeah, you will always need to at least import Foundation before you do anything! I usually import UIKit instead of Foundation, because almost always I will need to use features of UIKit and UIKit has inherits everything from Foundation for you. Imports with Objc can be pretty tricky, but it looks like you were using Swift? Commented Oct 2, 2017 at 18:05
  • Yes I was using Swift, the file at hand wasn't showing any compiler issues, but only during running the file, I ran into this issue!
    – mfaani
    Commented Oct 2, 2017 at 18:10
  • 1
    Yeah, I don't think it really checks for that until runtime, I could be wrong. But, it seems like it wouldn't have an issue until you were trying to access something from Foundation, couldn't find the import, then couldn't continue the process -- crash! Commented Oct 2, 2017 at 18:49
1

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.

1
  • 1
    It definitely seems like a file issue they are trying to hint at...Files elsewhere are not retrieving information from one another seems commonly found on this page. Thanks for your reply. Hoping it helps someone down the road! Commented Oct 23, 2017 at 17:13
1

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.

1

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.

1

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.

1

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

0

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.

1
  • good note..but usually the console will let you know that some files are too large to be transferred? Commented Apr 21, 2019 at 1:01
0

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

0

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)
0

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

0

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

0

for me the issue occurred with xcode 14, some frameworks on pods had minimum deployment target on ios 8.0, to fix the issue I added the following to pod file:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "12.0"
     end
  end
end
0

I resolved this issue by deleting node modules, lock file, Pods, and podfile.lock and reinstall nod modules and pods.

You can hit the below command for simplicity:

  • rm -rf node_modules && rm -rf ios/build && rm -rf ios/Pods && rm -rf ios/Podfile.lock && yarn && npx pod-install
0

MY SOLUTION: I tried many options, but none of them helped, I started to delete everything from the project and after deleting one script, everything worked for me. This script was NativeShare.cs Here is part of code which is potentially broke the project:

#if UNITY_IOS
    public struct ConfigStruct
    {
        public string title;
        public string message;
    }

    [DllImport ("__Internal")] private static extern void showAlertMessage(ref ConfigStruct conf);
    
    public struct SocialSharingStruct
    {
        public string text;
        public string url;
        public string image;
        public string subject;
    }
    
    [DllImport ("__Internal")] private static extern void showSocialSharing(ref SocialSharingStruct conf);
    
    public static void CallSocialShare(string title, string message)
    {
        ConfigStruct conf = new ConfigStruct();
        conf.title  = title;
        conf.message = message;
        showAlertMessage(ref conf);
    }

    public static void CallSocialShareAdvanced(string defaultTxt, string subject, string url, string img)
    {
        SocialSharingStruct conf = new SocialSharingStruct();
        conf.text = defaultTxt; 
        conf.url = url;
        conf.image = img;
        conf.subject = subject;
        
        showSocialSharing(ref conf);
    }
#endif

Hope it will help someone

-1

The solution that worked for me is changing all podfiles minimum deployable version to 11.0

You can also do this by adding a script to the bottom of our podfile:

    post_install do |installer|
    installer.generated_projects.each do |project|
          project.targets.each do |target|
              target.build_configurations.each do |config|
                  config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = 
    '11.0'
               end
          end
       end
    end
-5

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.

2
  • I do not think this is helpful for this thread...It seems like the error is trying to get at a file issue, like importing the same thing in separate files. I find it strange you would get this error, because this is an Objective-C specific error... Commented Aug 20, 2018 at 17:16
  • I got this error in C++ too. The linker error in your case was probably that the linker couldn't find the code for your constructor. I had a similar error with a function that I renamed but because Xcode 10 wouldn't open the linker log on its own, and I didn't know you could right-click and "reveal in log", I was stumped for a few minutes trying to locate the error. Commented Oct 13, 2018 at 7:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.