Duplicate Symbols for Architecture arm64

前端 未结 24 2495
礼貌的吻别
礼貌的吻别 2020-12-02 16:21

When I try running my Xcode Project it fails with an error stating that I have duplicate symbols. I looked online where the find these duplicates but have had no luck:

相关标签:
24条回答
  • 2020-12-02 16:43

    This error happens when Linker is trying to link the obj files. Few reasons that i could think of for this error are:

    1. The duplicated Function/Class is defined at two different places/files in the project and only one of them was supposed to compile for any variation of build command. But somehow both those files got compiled in your project. So you need to check your if-else conditions or other dependencies which adds src files to the list of files needed to be compiled and remove the un-needed file for your particular build command.

    2. The duplicated Function/Class is defined accidentally at two different places/files in the project. Remove the wrong definition.

    3. Clean your OBJ directory before you build again, there could be some old obj files in there from your previous builds which might be causing this conflict.

    P.S i am no expert, but this is how i solved this problem when i faced it. :)

    0 讨论(0)
  • 2020-12-02 16:47

    Below Patch work for me..:)

    Step 1: Go to TARGETS -> Build Settings -> No Common Blocks -> No
    
    Step 2: Go to TARGETS -> Build Settings -> enable testability -> No
    

    Setting it back to NO solved the problem!

    0 讨论(0)
  • 2020-12-02 16:47

    Well, some times when using SDK like FB or Libraries like Vuforia or GoogleAnalytics , adding sample projects may cause the problem that they're already including Frameworks and like so ,so you must make sure not repeating symbols you add manually while they're already included in samples

    0 讨论(0)
  • 2020-12-02 16:48

    Another Solution is to:

    Select Project -> Target -> Build phase -> Compile source -> search for the file which is mentioned in the 3rd last error line (In your case BFAppLinkReturnToRefererView.o).

    Then you will see either 1 or 2 files in search result.

    Remove one of them and compile again. It should recompile now because there is only one file left and no more conflicts for build.

    If that doesnt work the file probably has errors in it and you should remove all of them and then recompile. It should work again.

    0 讨论(0)
  • 2020-12-02 16:49

    In my case reason was too stupid :

    I had a Constant.h file where I had macros defined. I thought of doing NSString there. and did this :

    NSString const *kGreenColor = @"#00C34E";
    

    this caused the problem of Duplicate Symbols for Architecture arm64 and Linker command failed with exit code 1. Removing const NSString line worked for me.

    0 讨论(0)
  • 2020-12-02 16:50

    I was able to resolve this error which said "158 duplicate symbols for architecture armv7, 158 duplicate symbols for architecture arm64" --- If this is what you are getting too, then it means you are trying to compile a file which is importing or inheriting a framework or static library having references to C++ code or files. An easy way to handle this would be to change the extension of your .m file to .mm. This is how it gets handled if you are using Objective C, not sure on Swift though.

    Also in your build settings - you can update the "other linker flags" to -lc++

    0 讨论(0)
提交回复
热议问题