xcode duplicate symbols for architecture error after updating cocoa pods

10,319

Solution 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

Solution 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\""

Solution 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

Solution 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)";
Share:
10,319
Ale
Author by

Ale

Updated on June 22, 2022

Comments

  • Ale
    Ale almost 2 years

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