Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解决ios中第三方框架中的重复符号?_Ios_Google Plus_Amazon - Fatal编程技术网

如何解决ios中第三方框架中的重复符号?

如何解决ios中第三方框架中的重复符号?,ios,google-plus,amazon,Ios,Google Plus,Amazon,我正在我的项目中开发Amazon登录和Google Plus共享。我在我的项目中添加了Amazon和Google plus框架。当我尝试构建项目时,它显示“GooglePlus和Amazon框架中的重复符号”错误 错误消息 duplicate symbol _kClientId in: /Users/test/Amazon/Apps-SDK/iOS/LoginWithAmazon/LoginWithAmazon.framework/LoginWithAmazon(AIConstants.o)

我正在我的项目中开发Amazon登录和Google Plus共享。我在我的项目中添加了Amazon和Google plus框架。当我尝试构建项目时,它显示“GooglePlus和Amazon框架中的重复符号”错误

错误消息

 duplicate symbol _kClientId in:
/Users/test/Amazon/Apps-SDK/iOS/LoginWithAmazon/LoginWithAmazon.framework/LoginWithAmazon(AIConstants.o)
/Users/test/GooglePlus/google-plus-ios-sdk-1.5.1/GooglePlus.framework/GooglePlus(GPPOzLogger.o)
 ld: 1 duplicate symbol for architecture i386
 clang: error: linker command failed with exit code 1 (use -v to see invocation)

如何解决这种错误

你真正能做的就是联系谷歌和/或亚马逊,告诉他们修复相互冲突的框架。当与这样的名称发生冲突的可能性非常高时,他们在框架中使用全局符号名称(如
\u kClientId
)有点愚蠢。对于每个相应的框架,名称应该是像
\u kGooglePlus\u iOS\u Framework\u ClientId
\u kAmazon\u iOS\u Framework\u ClientId
这样的长,以减少符号名称冲突的机会


如果可以的话,可以为Google Plus或Amazon使用不同的框架或库。或者,如果不能这样做,请使用十六进制编辑器手动更改其中一个框架中对
\u kClientId
符号的所有引用。

我以前也遇到过同样的问题。我终于想出了解决这个问题的办法。 作为图书馆的客户,我们不能回避它,但我们仍然有机会处理它。 我的回答包括两个部分,一个是描述问题,一个是作为框架的客户解决这个问题(这意味着我们必须自己解决这个问题,而不是要求框架的开发人员解决这个问题)

1)冲突是如何发生的,链接错误是什么意思?

一个框架实际上是一个文件夹,输入框架你会发现一个lib文件。有时lib文件的扩展名为*.a,或者没有扩展名。lib文件的结构如下所示:

libFoo.a  /  i386  /
                      hello.o
                      world.o
             arm64 /  
                      hello.o
                      world.o
在本例中,libFoo.a是一个fat库,这意味着它包含多个体系结构。链接错误告诉您在同一体系结构中有两个库包含相同的.o(符号)文件

例如,您的案例:

duplicate symbol _kClientId in:
/Users/test/Amazon/Apps-SDK/iOS/LoginWithAmazon/LoginWithAmazon.framework/LoginWithAmazon(AIConstants.o)
/Users/test/GooglePlus/google-plus-ios-sdk-1.5.1/GooglePlus.framework/GooglePlus(GPPOzLogger.o)
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这意味着在这两个框架中,i386体系结构中有重复的.o文件

2)如何解决问题。

我们需要一些工具来解决这个问题。幸运的是,你应该在电脑中安装这些工具。 我们需要做的是打开一个框架,做一些手术来移除重复的符号并将其关闭

我在这里演示了在i386架构下删除LoginWithAmazon中重复符号AIConstants.o的过程:

lipo -info LoginWithAmazon //this is going to show us the architectures in the fat library
lipo LoginWithAmazon -thin i386 -output LoginWithAmazon-i386 //we extract the i386 architecture as xxx-i386 from fat library
//use the same command to extract every architecture from fat libraray as xxx-archname

ar -t LoginWithAmazon-i386 // list of symbols in this architecture, we should see AIConstants.o in it
ar -d LoginWithAmazon-i386 AIConstants.o // delete AIConstants.o from LoginWithAmazon-i386
//now work is done, we put everything back to the fat library

lipo LoginWithAmazon-i386 LoginWithAmazon-arm64 <every architecture you extracted from the fat library> -create -output LoginWithAmazon-new
ranlib -s LoginWithAmazon-new //sometime we need to rebuild the symbol table
//now you have done the work, use LoginWithAmazon-new to replace the old LoginWithAmazon, and try to compile your program again
lipo-info LoginWithAmazon//这将向我们展示fat库中的架构
lipo LoginWithAmazon-thin i386-output LoginWithAmazon-i386//我们从fat库中将i386架构提取为xxx-i386
//使用相同的命令从fat LIBRARY中将每个架构提取为xxx archname
ar-t LoginWithAmazon-i386//在这个架构中的符号列表中,我们应该可以看到AIConstants.o
ar-d LoginWithAmazon-i386 AIConstants.o//从LoginWithAmazon-i386中删除AIConstants.o
//现在工作完成了,我们把所有的东西都放回fat库
lipo LoginWithAmazon-i386 LoginWithAmazon-arm64-创建-输出LoginWithAmazon新建
ranlib-s LoginWithAmazon new//有时我们需要重建符号表
//现在您已经完成了工作,使用LoginWithAmazon new替换旧的LoginWithAmazon,然后再次尝试编译您的程序
REF:


对于amazon团队的登录,这个问题似乎不是很重要

作为一种临时解决方案(信不信由你),你可以使用文本编辑器,用其他东西(比如“kClientIe”)替换登录WithAmazon二进制文件中出现的所有“kClientId”

请参见我的回答:


是否有其他框架或任何其他方式来实现google+共享?@harigharan,我不知道,没有。你可能只需要用google来实现它。或者Bing它–无论你喜欢哪个。很好的描述,但是这不起作用,因为你还从AIConstants.o中删除了所有其他常量,这将使链接器无法进行所有其他_k*引用。我假设两个版本的AIConstants.o具有相同的内容。如果不是这样的话,您需要框架源代码来重建不太可能发生的事情。