iOS - 2 duplicate symbols for architecture armv7

喜欢而已 提交于 2019-12-12 10:41:42

问题


I am using Resty everywhere in my project, but now since I have to upload image to server, so I try to add another framework called RestKit to handle file upload. But when I compiled, it got error:

duplicate symbol _NewBase64Decode in:
    /Users/iforests/Library/Developer/Xcode/DerivedData/Owlch-gnysrakcbhsgkubbjjjfbahlocqi/Build/Products/Debug-iphoneos/libRestKit.a(NSData+Base64.o)
    /Users/iforests/Documents/iOSworkspace/Owlch/LRResty.framework/LRResty(NSData+Base64.o)
ld: 2 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is there any way to solve this problem without removing LRResty (since tomorrow is the deadline of this project). Thank you all so much!


回答1:


Delete these files from the Resty source.

LRResty/Classes/Categories/NSData+Base64.h LRResty/Classes/Categories/NSData+Base64.m

That will take care of the linking issue.

If it stops working because of that, rename the files and category for NSData+Base64 in the Resty code and then anywhere the Resty code imports "NSData+Base64.h", change the import to whatever you rename the category




回答2:


Just had this issue when importing a new library into an existing (old) project - turns out the problem was the linker flag -all_load that was (for whatever reason) still set in the "Build Settings - Linking - Other Linker Flags" in Xcode.

After removing this flag all went fine.




回答3:


I also came up with same error. Generally this kind of error occurs due to duplicate classes and xibs in project folder. For Example in my project I had these classes twice ServiceRequest.h/.m. Get rid of duplicate ones and you are good to go.




回答4:


The issue is that both libraries are defining the same method: NewBase64Decode.

So you could modify the source code of any one library and change the method name to something else like "RKNewBase64Decode". Remember to make changes in the *.m file as well wherever NewBase64Decode method is invoked!




回答5:


Also, I have noted, if you have stupidly imported a .m, remove the import.




回答6:


This occurred to me when importing a framework that contained a class with the exact same name as there was in the project.



来源:https://stackoverflow.com/questions/12200238/ios-2-duplicate-symbols-for-architecture-armv7

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