Search code examples
xcodestatic-librariesduplicate-symbol

Xcode - Duplicate Symbol Occured in Source Files of Project and Static Lib


We have a static library (libAudioBulb.a) in which I use for almost all the projects here. The static library contains source files of AFNetworking. In one of my projects, I need to use AFNetworking as well, however, when I included the source files of AFNetworking, there is a build time error showing that I have duplicate symbols in the project and the static library. But, the strange thing is, in another project, I just did the same thing but there is no build time error. So, is there any build settings that I need to configure here?

duplicate symbol _AFNetworkingTaskDidFinishErrorKey in:
    /Users/jun/Library/Developer/Xcode/DerivedData/Enwave_Pro-blvydexcmotpqigieicimmkbrlnw/Build/Intermediates/Enwave Pro.build/Debug-iphoneos/Enwave Pro.build/Objects-normal/armv7/AFURLSessionManager.o
    /Users/jun/Desktop/Projects/Multiroom/App/Enwave Pro/enwave_pro-ios/Enwave Pro/Sources/MultiroomPlay/libAudioBulb.a(AFURLSessionManager.o)
duplicate symbol _AFNetworkingTaskDidCompleteErrorKey in:
    /Users/jun/Library/Developer/Xcode/DerivedData/Enwave_Pro-blvydexcmotpqigieicimmkbrlnw/Build/Intermediates/Enwave Pro.build/Debug-iphoneos/Enwave Pro.build/Objects-normal/armv7/AFURLSessionManager.o
    /Users/jun/Desktop/Projects/Multiroom/App/Enwave Pro/enwave_pro-ios/Enwave Pro/Sources/MultiroomPlay/libAudioBulb.a(AFURLSessionManager.o)
duplicate symbol _AFNetworkingTaskDidFinishResponseSerializerKey in:
    /Users/jun/Library/Developer/Xcode/DerivedData/Enwave_Pro-blvydexcmotpqigieicimmkbrlnw/Build/Intermediates/Enwave Pro.build/Debug-iphoneos/Enwave Pro.build/Objects-normal/armv7/AFURLSessionManager.o
    /Users/jun/Desktop/Projects/Multiroom/App/Enwave Pro/enwave_pro-ios/Enwave Pro/Sources/MultiroomPlay/libAudioBulb.a(AFURLSessionManager.o)
duplicate symbol _AFNetworkingTaskDidCompleteResponseSerializerKey in:
    /Users/jun/Library/Developer/Xcode/DerivedData/Enwave_Pro-blvydexcmotpqigieicimmkbrlnw/Build/Intermediates/Enwave Pro.build/Debug-iphoneos/Enwave Pro.build/Objects-normal/armv7/AFURLSessionManager.o
    /Users/jun/Desktop/Projects/Multiroom/App/Enwave Pro/enwave_pro-ios/Enwave Pro/Sources/MultiroomPlay/libAudioBulb.a(AFURLSessionManager.o)
duplicate symbol _AFNetworkingTaskDidFinishAssetPathKey in:
    /Users/jun/Library/Developer/Xcode/DerivedData/Enwave_Pro-blvydexcmotpqigieicimmkbrlnw/Build/Intermediates/Enwave Pro.build/Debug-iphoneos/Enwave Pro.build/Objects-normal/armv7/AFURLSessionManager.o
    /Users/jun/Desktop/Projects/Multiroom/App/Enwave Pro/enwave_pro-ios/Enwave Pro/Sources/MultiroomPlay/libAudioBulb.a(AFURLSessionManager.o)
duplicate symbol _AFNetworkingTaskDidCompleteAssetPathKey in:
    /Users/jun/Library/Developer/Xcode/DerivedData/Enwave_Pro-blvydexcmotpqigieicimmkbrlnw/Build/Intermediates/Enwave Pro.build/Debug-iphoneos/Enwave Pro.build/Objects-normal/armv7/AFURLSessionManager.o
    /Users/jun/Desktop/Projects/Multiroom/App/Enwave Pro/enwave_pro-ios/Enwave Pro/Sources/MultiroomPlay/libAudioBulb.a(AFURLSessionManager.o)

Solution

  • I found two ways to solve this:

    1. If -ObjC is set under other linker flags, then that would cause the duplication. So remove that if it is not needed.

    2. If option 1 cannot be done then removing the .m files of the conflicting classes in one of the project that includes those classes will do.