ios Xcode 下架构 x86_64 的重复符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24298144/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 00:57:54  来源:igfitidea点击:

Duplicate symbols for architecture x86_64 under Xcode

iosobjective-cxcode5

提问by lee

I now have the same question with above title but have not found the right answer yet. I got the error:

我现在有与上述标题相同的问题,但还没有找到正确的答案。我得到了错误:

    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Intermediates/TestMoboSDK-Client.build/Debug-iphonesimulator/TestMoboSDK-Client.build/Objects-normal/x86_64/MoboSDK.o
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Products/Debug-iphonesimulator/libMoboSDK.a(MoboSDK.o)
duplicate symbol _OBJC_METACLASS_$_MoboSDK in:
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Intermediates/TestMoboSDK-Client.build/Debug-iphonesimulator/TestMoboSDK-Client.build/Objects-normal/x86_64/MoboSDK.o
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Products/Debug-iphonesimulator/libMoboSDK.a(MoboSDK.o)
ld: 75 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any help is appreciated.

任何帮助表示赞赏。

Finally?I find out the reason of this error cause I added -ObjCto the Other Linker Flags. After remove this value then I can build my project successfully, but I don't know why. Can anyone explain this?

最后?我找出了这个错误的原因,因为我添加-ObjCOther Linker Flags. 删除此值后,我可以成功构建我的项目,但我不知道为什么。谁能解释一下?

采纳答案by David V

75 duplicate symbols for architecture x86_64

架构 x86_64 的 75 个重复符号

Means that you have loaded same functions twice. As the issue disappear after removing -ObjCfrom Other Linker Flags,this means that this option result that functions loads twice:

意味着您已两次加载相同的功能。由于问题在-ObjC从中删除后消失 Other Linker Flags,意味着此选项导致函数加载两次:

from Technical Q&A

来自技术问答

This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes.

此标志使链接器加载库中定义 Objective-C 类或类别的每个目标文件。虽然此选项通常会导致更大的可执行文件(由于加载到应用程序中的额外目标代码),但它允许成功创建包含现有类类别的有效 Objective-C 静态库。

https://developer.apple.com/library/content/qa/qa1490/_index.html

https://developer.apple.com/library/content/qa/qa1490/_index.html

回答by Linda MacPhee-Cobb

For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation ) fixed the problem.

对我来说,将“No Common Blocks”从 Yes 更改为 No(在 Targets->Build Settings->Apple LLVM - Code Generation 下)解决了这个问题。

回答by Adam Waite

Stupid one, but make sure you haven't #imported a .mfile by mistake somewhere

愚蠢的,但请确保您没有#import.m某处错误地编辑文件

回答by Sauvik Dolui

In my case, I just created a header file to define constant strings like this:

就我而言,我刚刚创建了一个头文件来定义这样的常量字符串:

NSString *const AppDescriptionString = @"Healthy is the best way to keep fit";

I solved this scenario by using static:

我通过使用解决了这个场景static

static NSString *const AppDescriptionString = @"Healthy is the best way to keep fit";

回答by simon_smiley

I found the accepted answer touches on the problem but didn't help me solve it, hopefully this answer will help with this very frustrating issue.

我发现接受的答案触及了这个问题,但没有帮助我解决它,希望这个答案能帮助解决这个非常令人沮丧的问题。

duplicate symbol _OBJC_IVAR_$_BLoginViewController._hud in:

17 duplicate symbols for architecture x86_64

"Means that you have loaded same functions twice. As the issue disappear after removing -ObjC from Other Linker Flags, this means that this option result that functions loads twice:"

“意味着您已两次加载相同的函数。由于从其他链接器标志中删除 -ObjC 后问题消失,这意味着此选项导致函数加载两次:”

In layman's terms this means we have two files in our project with exactly the same name. Maybe you are combining one project into another one? Have a look at the errors above the "duplicate symbols" error to see which folder is duplicated, in my case it was BLoginViewController.

通俗地说,这意味着我们的项目中有两个文件名完全相同。也许您正在将一个项目合并到另一个项目中?查看“重复符号”错误上方的错误以查看哪个文件夹重复,在我的情况下是 BLoginViewController。

For example, in the image below you can see I have two BImageViewControllers, for me this is what was causing the issue.

例如,在下图中您可以看到我有两个 BImageViewControllers,对我来说这就是导致问题的原因。

As soon as I deleted one then the issue vanished :)

一旦我删除了一个,问题就消失了:)

enter image description here

在此处输入图片说明

回答by Dr. chamran

I have same problem. In Xcode 7.2 in path Project Target > Build Setting > No Common Blocks, i change it to NO.

我有同样的问题。在路径 Project Target > Build Setting > No Common Blocks 中的 Xcode 7.2 中,我将其更改为 NO。

回答by Blaszard

This occurred on me when I accepted "recommended settings" pop-up on a project that I develop two years ago in Objective-C.

当我在两年前在 Objective-C 中开发的一个项目中接受“推荐设置”弹出窗口时,发生了这种情况。

The problem was that when you accepted the "recommended settings" update, Xcode automatically changed or added some build settings, including GCC_NO_COMMON_BLOCKS = YES;.

问题在于,当您接受“推荐设置”更新时,Xcode 会自动更改或添加一些构建设置,包括GCC_NO_COMMON_BLOCKS = YES;.

This made the build failed with the duplicate symbolerror in my updated project. So I changed No Common Blockto NOin my build settings and the error was gone.

这使得构建失败,并duplicate symbol在我更新的项目中出现错误。所以我在我的构建设置中更改No Common BlockNO并且错误消失了。

回答by Luca Davanzo

Happens also when you declare const variables with same name in different class:

当您在不同的类中声明具有相同名称的 const 变量时也会发生:

in file Message.m

在文件 Message.m 中

const int kMessageLength = 36;

@implementation Message

@end

in file Chat.m

在文件 Chat.m 中

const int kMessageLength = 20;

@implementation Chat

@end

回答by J. Goce

Fastest way to find the duplicate is:

查找重复项的最快方法是:

  1. Go to Targets
  2. Go to Build Phases
  3. Go to Compile Sources
  4. Delete duplicate files.
  1. 前往目标
  2. 转到构建阶段
  3. 转到编译源
  4. 删除重复文件。

回答by pigeon

Following steps solved the issue for me.

以下步骤为我解决了这个问题。

  1. Go to Build Phases in Target settings.
  2. Go to “Link Binary With Libraries”.
  3. Check if any of the libraries exist twice.
  4. Build again.
  1. 转到目标设置中的构建阶段。
  2. 转到“将二进制文件与库链接”。
  3. 检查任何库是否存在两次。
  4. 再建。