xcode 架构 armv7 的 106 个重复符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13727167/
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-09-15 02:15:16  来源:igfitidea点击:

106 duplicate symbols for architecture armv7

objective-ciosxcodearmv7cocoapods

提问by jdog

Working on my iPhone app and trying to build for debug and I get "106 duplicate symbols for architecture armv7"?

使用我的 iPhone 应用程序并尝试构建以进行调试,但我收到“架构 armv7 的 106 个重复符号”?

I am using the .workspace file because I am trying to use CocoaPods. If I don't use the .workspace and instead use the .xcodeproj I don't get the error, but then I get missing -lPods .

我正在使用 .workspace 文件,因为我正在尝试使用 CocoaPods。如果我不使用 .workspace 而是使用 .xcodeproj 我不会收到错误消息,但是我会丢失 -lPods 。

In my project I have the following targets in the Project Navigator.

在我的项目中,我在项目导航器中有以下目标。

Pods (blue icon)
MyProject (blue icon)
  Restkit.xcodeproj (blue icon)
  ... all my files

The issue is that Restkit is making reference to "AFHTTPClient.h" and all the other AF code, but I included it via CocoaPods. I tried deleting the AFNetworking folder from the RestKit library, but apparently the Restkit library can't find the Pods version of AFNetworking?

问题是 Restkit 引用了“AFHTTPClient.h”和所有其他 AF 代码,但我通过 CocoaPods 将其包含在内。我尝试从 RestKit 库中删除 AFNetworking 文件夹,但显然 Restkit 库找不到 AFNetworking 的 Pods 版本?

Is there a way to get RestKit to use the Pods version? If not how do I go about removing Pods from my project?

有没有办法让 RestKit 使用 Pods 版本?如果不是,我该如何从我的项目中删除 Pod?

回答by fnc12

There is a line in one of your .h files where your wrote

您的其中一个 .h 文件中有一行是您写的

#include "___.m"

instead of

代替

#include "___.h"

回答by JeffRegan

In Build Phases -> Compile Sources, make sure you don't have the same file added twice.

在 Build Phases -> Compile Sources 中,确保您没有添加两次相同的文件。

回答by Daniel Rivera

"Duplicate symbols for architecture" issue occurs in two situations:

建筑符号重复”问题出现在两种情况下:

  1. You added a .m file twice into your project

  2. You're using a static library (.a file) which already includes some classes that you include into the project.

  1. 您在项目中两次添加了 .m 文件

  2. 您正在使用一个静态库(.a 文件),它已经包含了一些您包含在项目中的类。

For fixing any of those cases, check the linker error and look for the .o files that are duplicated (sample: Reachability.o).

要修复任何这些情况,请检查链接器错误并查找重复的 .o 文件(示例:Reachability.o)​​。

Then go to the build phases -> compile sourcesand search the specified files, if any one appears twice delete one of them, if only appears once it means that the file is also included in one of the static libraries added to your project. Delete it from your list of sources to be compiled and try again.

然后转到构建阶段-> 编译源并搜索指定的文件,如果任何一个出现两次删除其中一个,如果只出现一次则表示该文件也包含在添加到项目中的静态库之一中。从要编译的源列表中删除它,然后重试。

回答by jdog

So I fixed it. After removing the RestKit version of AFNetworking, from the vendor folder, I added it back by dragging into Xcode. It asks which project I want it used/copied to and this time I selected RestKitTest (or whatever the RestKitTesting is named). It works now. Maybe I selected both RestKit and RestKitTest before, which was wrong?

所以我修好了。从供应商文件夹中删除 AFNetworking 的 RestKit 版本后,我通过拖入 Xcode 将其添加回来。它询问我希望它使用/复制到哪个项目,这次我选择了 RestKitTest(或任何命名的 RestKitTesting)。它现在有效。也许我之前同时选择了 RestKit 和 RestKitTest,这是错误的?

回答by rohan-patel

I also came up with same error. Generally this kind of error occurs due to duplicate classes and xibs in project folder. For Example in my project I had these classes twice ServiceRequest.h/.m. Get rid of duplicate ones and you are good to go.

我也想出了同样的错误。通常这种错误是由于项目文件夹中的重复类和 xib 引起的。例如,在我的项目中,我有两次这些课程ServiceRequest.h/.m。摆脱重复的,你就可以开始了。

回答by Tejasvi Manmatha

  • I saw this error when, I did drag and drop my calabash framework onto xcode and selected add to targets option in the window thats shown. Basically there were two references to files added I had to remove the calabash framework manually

  • Right way of doing it

    copy to calabash framework to project directory then go to xcode project Choose target -> Build phases -> Link Binary With Libraries and add the frame work using + button

  • 当我将我的葫芦框架拖放到 xcode 上并在显示的窗口中选择添加到目标选项时,我看到了这个错误。基本上有两个对文件的引用我不得不手动删除葫芦框架

  • 正确的做法

    复制到葫芦框架到项目目录然后转到 xcode 项目选择目标 -> 构建阶段 -> 链接二进制与库并使用 + 按钮添加框架工作

回答by Justas

I have noticed that duplicate symbols are caused for Google analytics after installing cocoaPods as well. Once I removed one of archives, either libGoogleAnalytics_debug.a or libGoogleAnalytics.a duplication has gone. But obviously if I removed debug one I will not be able to run os simulator and vica versa. I know its not the solution, but at least it could give an idea what could be a solution. Will come back to this thread if I will figure out how to have both a files in this case.

我注意到在安装 cocoaPods 后,Google 分析也会产生重复的符号。一旦我删除了其中一个档案,libGoogleAnalytics_debug.a 或 libGoogleAnalytics.a 重复就消失了。但很明显,如果我删除了 debug one,我将无法运行 os 模拟器,反之亦然。我知道它不是解决方案,但至少它可以给出一个解决方案的想法。如果我想知道如何在这种情况下同时拥有两个文件,我会回到这个线程。

Edit: I was able to solve the issue by upgrading from G analytics version 2 to 3. It has only one library file and I guess this is the reason why we don't get duplicated symbols anymore. I hope it makes sense.

编辑:我能够通过从 G 分析版本 2 升级到 3 来解决这个问题。它只有一个库文件,我想这就是我们不再得到重复符号的原因。我希望这是有道理的。