Cocoapods remove duplicate symbols for architecture i386 error

When we used two or more 3rd party library in our project using Cocoapods then there are possibility of duplicate symbols used by different libraries. In my case, I just added some pod and after nothing works anymore. I get more than 482 duplicate symbols for architecture i386 errors, like this one:

duplicate symbol _OBJC_IVAR_$_AFHTTPRequestOperation._responseSerializer in:
... (482 times the same error but pointing to different duplicated files)
ld: 482 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Reason of this error

The main reason of duplicate symbols error is const and extern variable used by one library similar to other library.


Best solution to remove the duplicate symbols error is, post_install Hook.

The Podfile provides hooks that will be called during the installation process. Hooks are global and not stored per target definition.

post_install Hook - 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. So, to avoid the duplicate symbol I added the post_install in the Podfile

Add post_install in your PodFile just after platform :ios, '8.0' line, to manually rename all of the symbols

platform :ios, '8.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'

Delete the following pod item's from your project
1.Pods Folder

And then install the pods again using pod install command.


Read Community Guidelines
You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.