xcode duplicate symbols for architecture error after updating cocoa pods

爱⌒轻易说出口 提交于 2019-12-30 03:26:21

问题


Here is my 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:

  • AFNetworking
  • CocoaAsyncSocket
  • IQKeyboardManager

After that, nothing works anymore.

I get more than 600 duplicate symbols for architecture i386 errors, like this one:

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


回答1:


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.

Replace your pod file content with this to 'Manually Rename All of the Symbols'

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

1.Pods Folder

2.Podfile.lock

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.

Reference -
1. https://developerinsider.co/cocoapods-remove-duplicate-symbols-errors/
2. http://guides.cocoapods.org/syntax/podfile.html#post_install




回答2:


Even after deleting my pods and reinstalling them, I had always the same problem.

I finally found the solution by comparing with another project. The issue was in the parameter "Other Linker Flags" (OTHER_LDFLAGS) in the Build Settings of the project. The pods were referenced not just by their name, but by adding the prefix "Pods-myProject"

"-l\"Pods-myProject-AMSlideMenu\"",
"-l\"Pods-myProject-CocoaLumberjack\"",
"-l\"Pods-myProject-DLAlertView\""

So I just removed the prefix and all was right

"-l\"AMSlideMenu\"",
"-l\"CocoaLumberjack\"",
"-l\"DLAlertView\""



回答3:


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 deintegrate
pod install



回答4:


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.

Before inside Build Settings:

OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", "-all_load" );

After inside Build Settings:

OTHER_LDFLAGS = "$(inherited)";



回答5:


I think Cocoapods has a bug where pod source files can be accidentally duplicated.

My project was building fine until after performing one pod update at which point a duplicate symbol error appeared.

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.

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.

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.

Also, this may explain why some "solutions" associated with this problem are to remove/delete referenced pods, then re-add.




回答6:


What worked for me:

  1. Read the error report to identify the repo that supposedly contains duplicate files.
  2. Drag the offending repo to the trash.
  3. re-clone your repo.
  4. set up your repo with correct remote tracking. git remote add <url.git>, or 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.

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.



来源:https://stackoverflow.com/questions/32605504/xcode-duplicate-symbols-for-architecture-error-after-updating-cocoa-pods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!