更新可可豆荚后,xcode 出现架构错误的重复符号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32605504/
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
xcode duplicate symbols for architecture error after updating cocoa pods
提问by Ale
Here is my podFile
:
这是我的podFile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
pod 'AFNetworking'
pod 'ODSAccordionView', '0.4.4'
pod 'IQKeyboardManager'
pod 'NYXImagesKit', :git => 'https://github.com/Nyx0uf/NYXImagesKit.git'
pod 'PEPhotoCropEditor'
pod 'CocoaAsyncSocket'
pod 'PKRevealController'
pod 'Haneke', '~> 1.0'
pod 'MBProgressHUD', '~> 0.9.1'
pod 'RadioButton'
Everythig has been working fine for a long time, but now, when I update my pods (pod update
) these 3 pods get uptated:
Everythig 已经运行良好很长时间了,但是现在,当我更新我的 Pod ( pod update
) 时,这 3 个 Pod 得到更新:
AFNetworking
CocoaAsyncSocket
IQKeyboardManager
AFNetworking
CocoaAsyncSocket
IQKeyboardManager
After that, nothing works anymore.
在那之后,什么都不起作用了。
I get more than 600 duplicate symbols for architecture i386
errors, like this one:
我收到了 600 多个duplicate symbols for architecture i386
错误,如下所示:
duplicate symbol _OBJC_IVAR_$_AFHTTPRequestOperation._responseSerializer in:
/Users/myuser/Library/Developer/Xcode/DerivedData/MyProject-emjexnnjljambodthokzwpwcddhz/Build/Products/Debug-iphonesimulator/libPods-AFNetworking.a(AFHTTPRequestOperation.o)
/Users/myuser/Library/Developer/Xcode/DerivedData/MyProject-emjexnnjljambodthokzwpwcddhz/Build/Products/Debug-iphonesimulator/libAFNetworking.a(AFHTTPRequestOperation.o)
... (661 times the same error but pointing to different duplicated files)
ld: 661 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any ideas?
有任何想法吗?
EDITED:After doing the solution shown below, my project only compiles for iPad Air
and I can not Archive
anymore, i still get the same error...
编辑:在执行如下所示的解决方案后,我的项目只能编译iPad Air
而我不能Archive
再编译了,我仍然遇到相同的错误......
回答by Vineet Choudhary
I use the 'Manually Rename All of the Symbols' approach. I was experiencing the duplicate symbol _OBJC_METACLASS_$_PodsDummy_Pods
and so i added the post_install
in the Podfile
to avoid the duplicate symbol.
我使用“手动重命名所有符号”方法。我遇到了重复符号_OBJC_METACLASS_$_PodsDummy_Pods
,所以我在post_install
中添加了Podfile
以避免重复符号。
Replace your pod file content with this to 'Manually Rename All of the Symbols'
将您的 pod 文件内容替换为“手动重命名所有符号”
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
post_install do |installer_representation|
installer_representation.project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited), PodsDummy_Pods=SomeOtherNamePodsDummy_Pods'
end
end
end
pod 'AFNetworking'
pod 'ODSAccordionView', '0.4.4'
pod 'IQKeyboardManager'
pod 'NYXImagesKit', :git => 'https://github.com/Nyx0uf/NYXImagesKit.git'
pod 'PEPhotoCropEditor'
pod 'CocoaAsyncSocket'
pod 'PKRevealController'
pod 'Haneke', '~> 1.0'
pod 'MBProgressHUD', '~> 0.9.1'
pod 'RadioButton'
Edited :Delete the following pod item's from your project
已编辑:从您的项目中删除以下 pod 项
1.Pods Folder
1.Pods Folder
2.Podfile.lock
2.Podfile.lock
3.ProjectName.xcworkspace
3.ProjectName.xcworkspace
And then install the pods again
然后再次安装豆荚
This hook allows you to make any last changes to the generated Xcode project before it is written to disk or any other tasks you might want to perform.
此挂钩允许您在将生成的 Xcode 项目写入磁盘或您可能想要执行的任何其他任务之前对其进行任何最后更改。
Reference -
1. https://developerinsider.co/cocoapods-remove-duplicate-symbols-errors/
2. http://guides.cocoapods.org/syntax/podfile.html#post_install
参考 -
1. https://developerinsider.co/cocoapods-remove-duplicate-symbols-errors/
2. http://guides.cocoapods.org/syntax/podfile.html#post_install
回答by Omaty
Even after deleting my pods and reinstalling them, I had always the same problem.
即使在删除我的 pod 并重新安装它们之后,我也总是遇到同样的问题。
I finally found the solution by comparing with another project. The issue was in the parameter "Other Linker Flags" (OTHER_LDFLAGS)in the Build Settingsof the project. The pods were referenced not just by their name, but by adding the prefix "Pods-myProject"
通过与另一个项目的比较,我终于找到了解决方案。问题出在项目构建设置中的参数“其他链接器标志”(OTHER_LDFLAGS)中。这些 Pod 不仅通过名称引用,还通过添加前缀“Pods-myProject”来引用
"-l\"Pods-myProject-AMSlideMenu\"",
"-l\"Pods-myProject-CocoaLumberHyman\"",
"-l\"Pods-myProject-DLAlertView\""
So I just removed the prefix and all was right
所以我只是删除了前缀,一切正常
"-l\"AMSlideMenu\"",
"-l\"CocoaLumberHyman\"",
"-l\"DLAlertView\""
回答by Dan G
I fixed a similar error (after a messy Cocoapods upgrade) by simply removing and then re-adding the pods. Backup your project, then run:
我通过简单地删除然后重新添加 pod 来修复一个类似的错误(在混乱的 Cocoapods 升级之后)。备份您的项目,然后运行:
pod deintegrate
pod install
回答by Ramon Vasconcelos
In my case we had a project written in objective C and swift with a custom framework module inside and to solve the symbols duplication problem we had to remove all the flags from Other Linker Flags
under Build Settings of the project and the framework module.
在我的例子中,我们有一个用目标 C 和 swift 编写的项目,里面有一个自定义框架模块,为了解决符号重复问题,我们必须从Other Linker Flags
项目和框架模块的构建设置下删除所有标志。
Before inside Build Settings:
在内部构建设置之前:
OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", "-all_load" );
After inside Build Settings:
在内部构建设置之后:
OTHER_LDFLAGS = "$(inherited)";
回答by ScottyBlades
What worked for me:
什么对我有用:
- Read the error report to identify the repo that supposedly contains duplicate files.
- Drag the offending repo to the trash.
- re-clone your repo.
- set up your repo with correct remote tracking.
git remote add <url.git>
, orgit remote set-url <url.git>
- 阅读错误报告以识别可能包含重复文件的存储库。
- 将违规的回购拖到垃圾箱。
- 重新克隆你的回购。
- 使用正确的远程跟踪设置您的回购。
git remote add <url.git>
, 或者git remote set-url <url.git>
This absolutely worked for me. In my case for some elusive reason, when I ran git pull upstream develop
for a local dependency, git
would pull in/generate duplicate files from multiple commits.
这绝对对我有用。在我的情况下,出于某种难以捉摸的原因,当我运行git pull upstream develop
本地依赖项时,git
会从多个提交中拉入/生成重复文件。
After following the above steps, the issue went away and git pull upstream develop
was no longer pulling from multiple commits at once. Perhaps there was a weird git
cache for my repo.
按照上述步骤操作后,问题就消失了,git pull upstream develop
不再一次从多个提交中提取。也许git
我的回购有一个奇怪的缓存。
回答by Daniel
I think Cocoapods has a bug where pod source files can be accidentally duplicated.
我认为 Cocoapods 有一个错误,即 pod 源文件可能会被意外复制。
My project was building fine until after performing one pod update
at which point a duplicate symbol error appeared.
我的项目构建良好,直到执行一个之后pod update
出现重复符号错误。
After lots of confusion, I finally noticed that a Google pod ended up with two files. In my case, it was GTMOAuth2SignIn.m and GTMOAuth2SignIn 2.m. Hence, the duplicate symbol error.
经过一番混乱之后,我终于注意到一个 Google pod 最终有两个文件。就我而言,它是 GTMOAuth2SignIn.m 和 GTMOAuth2SignIn 2.m。因此,重复符号错误。
Note that pods seem to reference files by wildcards indicating all source in a directory should be included. This differs from a classic Xcode project where files are explicitly referenced.
请注意,pod 似乎通过通配符引用文件,指示应包含目录中的所有源。这与显式引用文件的经典 Xcode 项目不同。
Also, I suspect that performing a pod update during a build process could be what's tripping up Cocoapods. The concurrent access to the same file(s) may cause problems. Just a theory.
另外,我怀疑在构建过程中执行 pod 更新可能是导致 Cocoapods 失败的原因。对相同文件的并发访问可能会导致问题。只是一个理论。
Also, this may explain why some "solutions" associated with this problem are to remove/delete referenced pods, then re-add.
此外,这也可以解释为什么与此问题相关的一些“解决方案”是移除/删除引用的 pod,然后重新添加。