Linker command failed with exit code 1 (duplicate

2019-02-24 14:51发布

问题:

I developing a game in Unity and I have used Admob, Facebook and GameCenter in it. It was working fine on iOS until I have added the OpenIAB for in-app purchase, though it works fine in Unity Editor.

I am getting this error in xcode:

duplicate symbol __Z14MakeStringCopyPKc in: /Users/UmerAzeem/Library/Developer/Xcode/DerivedData/Unity-iPhone-ejwaywhkiokzjofdpwnbebkbleai/Build/Intermediates/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/armv7/FBUnityUtility.o /Users/UmerAzeem/Library/Developer/Xcode/DerivedData/Unity-iPhone-ejwaywhkiokzjofdpwnbebkbleai/Build/Intermediates/Unity-iPhone.build/Debug-iphoneos/Unity-iPhone.build/Objects-normal/armv7/AppStoreDelegate.o ld: 1 duplicate symbol for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

See error screenshot here

I have tried almost all the solution that I could find over the internet, but still don't understand how can I remove this duplication error, I have tried looking for duplicate files too, but it also went in vain, someone help me out of this, would appreciate it. Thanks.

回答1:

Look up in your project for:

MakeStringCopy

And make sure it exists (if exists) only once. If it appears more then once, rename one (make sure to rename it where it being called as well) and try to build again.



回答2:

I have recently face the same issue. I know Umer Azeem got the answer but to help someone else who may suffer from the same issue I was in.
According to my application flow I am using printer related third party class to print. To use that I have created object of that class in both of my files ImagePrintViewController and PrintResultViewController separately and passed required data to it.

In my scenario I am getting same error with variable name like _printerSetup in two of my files/Library/Developer/Xcode/DerivedData/../x86_64/ImagePrintViewController.o and /Library/Developer/Xcode/DerivedData/../x86_64/PrintResultViewController.o.
I have search in both of my file for the above variable name. But I couldn't find that.

After searching long on this I got a idea to delete reference of my second file i.e. BRPrintResultViewController.h and BRPrintResultViewController.m after merging code in my first file.

With this I found my solution and my code runs fine after this.