我正在使用Unrar4iOS.Framework
。它工作正常,但是当我添加-Objc其他链接器标志时。它给我重复的错误。
duplicate symbol __Z12CallbackProcjlll in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
/My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
duplicate symbol _OBJC_IVAR_$_Unrar4iOS.header in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
duplicate symbol _OBJC_IVAR_$_Unrar4iOS.flags in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
我不得不添加use Objc标志来使用其他库。
最佳答案
如果您指定-all_load或-Objc标志,并且静态库在项目中具有相同的类符号名称,则在链接时间中会看到这些“重复符号”错误。
原因?
该标志使链接器加载定义Objective-C类或类别的库中的每个对象文件。 虽然此选项通常会导致更大的可执行文件(由于将更多的目标代码加载到应用程序中),但它将允许成功创建有效的Objective-C静态库,其中包含现有类的类别。
从Apple官方文档中获取。
在您的项目中,现在,Unrar4iOS.o中的3个符号已崩溃。
例如,在您的第一个重复的符号错误日志中,
__Z12CallbackProcjlll符号在中崩溃了
(1)库/开发人员/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
(2)/我的项目/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
第二个和第三个重复符号将使用相同的模式。duplicate symbol __Z12CallbackProcjlll in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
/My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
duplicate symbol _OBJC_IVAR_$_Unrar4iOS.header in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
duplicate symbol _OBJC_IVAR_$_Unrar4iOS.flags in:
Library/Developer/Xcode/DerivedData/SARUnArchiveANY-fgljekydpkmvrlgapbahtfvvhsdl/Build/Intermediates/SARUnArchiveANY.build/Debug-iphonesimulator/SARUnArchiveANY.build/Objects-normal/x86_64/Unrar4iOS.o
My Project/SARUnArchiveANY-master/SARUnArchiveANY/vendor/Frameworks/Unrar4iOS.framework/Unrar4iOS(Unrar4iOS.o)
因此,总结您的项目症状,现在,在您的项目中, Unrar4iOS.framework和SARUnArchiveANY库彼此崩溃,并在Unrar4iOS目标文件中使用三个重复的符号。
另外,以下是SARUnArchiveANY git存储库介绍。
它已经指定了SARUnArchiveANY库,其中包含Unrar4iOS。
SARUnArchiveANY
一个非常有用的库,用于取消存档iOS的.zip,.rar,.7z文件。
只需集成以下库:
Unrar4iOS
SSZipArchive
LZMA SDK(7z)
来自https://github.com/saru2020/SARUnArchiveANY
为了解决该问题,我建议使用此链接。
http://atnan.com/blog/2012/01/12/avoiding-duplicate-symbol-errors-during-linking-by-removing-classes-from-static-libraries
您可以解决问题,因为我之前已经做过。
关于ios - -Objc其他链接器标志给出重复的符号错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39806128/