未定义符号和重复符号错误.可以针对调试或发布而构建,但不能同时针对两者进行构建 [英] Undefined symbols and duplicate symbols errors. Can build for debug, or release, but not both

查看:49
本文介绍了未定义符号和重复符号错误.可以针对调试或发布而构建,但不能同时针对两者进行构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对一个包含另一个项目的项目有疑问.第二个项目是主项目所需的SDK.目前,我已经将SDK作为一个静态库包含在主项目中.SDK和主要项目都包括FBConnect和非官方Twitter SDK框架.我相信我的问题是两个项目中都包含了这些框架的结果,但是我一直无法找到一种使它们并存而不会出错的方法.

I have an issue with a project that includes another project. The second project is an SDK which is required for the main project. At the moment, I have the SDK included in the main project as a static library. Both the SDK and the main project include the FBConnect and Unofficial Twitter SDK frameworks. I believe my problems are a result of these frameworks being included in both projects, but I have been unable to find a way to have them coexist without errors.

为调试而构建项目时,不会为归档而构建项目,反之亦然.通过执行相同的步骤,我每次都能解决问题,但是我想找到一种无需在调试和存档版本之间进行任何步骤即可解决的方法.

When the project builds for debug, it will not build for archive, and vice versa. I am able to resolve the issues each time by performing the same steps, but I would like to find a way to resolve it with no steps required between debug and archive builds.

当项目构建为调试而没有任何错误时,尝试归档构建时会得到以下信息:

When the project builds for debug without any errors, I get the following when trying an archive build:

Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_SBJSON", referenced from:
      objc-class-ref in FBRequest.o
      objc-class-ref in libSDK.a(ApiTvDiscussView.o)
      objc-class-ref in libSDK.a(ApiWebView.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

然后按照链接的屏幕截图,将FBConnect框架使用的SBJSON库的实现文件添加到目标的构建阶段中的编译源"中:

I then add the implementation files for the SBJSON library used by the FBConnect framework into the Compile Sources in Build Phases of the target, as per the linked screenshot: Screenshot

这会产生一个不同的问题,如下所示:

This then produces a different issue, as below:

    duplicate symbol _OBJC_METACLASS_$_OAHMAC_SHA1SignatureProvider in:
        /Users/Alan/Library/Developer/Xcode/DerivedData/App-gpvfsbaxxbvhsddtcbgkggquyltl/Build/Intermediates/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Objects-normal/armv7/OAHMAC_SHA1SignatureProvider.o
./libSDK.a(OAHMAC_SHA1SignatureProvider.o)

    .
    .
    .
    .
    .

    duplicate symbol _OBJC_CLASS_$_TwitterDialog in:
        /Users/Alan/Library/Developer/Xcode/DerivedData/App-gpvfsbaxxbvhsddtcbgkggquyltl/Build/Intermediates/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Objects-normal/armv7/TwitterDialog.o
        ./libSDK.a(TwitterDialog.o)
    duplicate symbol _OBJC_METACLASS_$_TwitterDialog in:
        /Users/Alan/Library/Developer/Xcode/DerivedData/App-gpvfsbaxxbvhsddtcbgkggquyltl/Build/Intermediates/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Objects-normal/armv7/TwitterDialog.o
        ./libSDK.a(TwitterDialog.o)
    ld: 43 duplicate symbols for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

从目标的构建阶段"中的编译源"中删除非官方Twitter SDK框架使用的OAUTH库的实现文件将消除这些错误,并且项目归档构建成功.

Removing the implementation files for the OAUTH library used by the Unofficial Twitter SDK framework from the Compile Sources in Build Phases of the target removes these errors and the project archive build is successful.

当我尝试构建项目进行调试时,我得到了与这些错误相反的信息,首先是OAUTH库符号未定义.将它们添加到编译源即可解决此问题,然后复制SBJSON符号.从编译源中删除它们可以使调试版本成功完成.

When I attempt to build the project for debug, I get the opposite of these errors, firstly the OAUTH library symbols are undefined. Adding them to compile sources resolves the issue, then the SBJSON symbols are duplicated. Removing them from compile sources allows the debug build to complete successfully.

有人知道一种使这些和谐共存的方法,这样我就可以调试和归档项目的构建,而不必每次都弄乱这个文件吗?

Does anyone know of a way to have these coexist in harmony so that I can do both debug and archive builds of the project without this file juggling every time?

推荐答案

Twitter和Facebook库都针对同一个SBJSON框架进行链接.通过代码而不是使用静态库来构建它们两者.这样做时,请从其中一个SDK中删除SBJSON引用.

Both the Twitter and Facebook libraries are linking against the same SBJSON framework. Build both of them from code instead of using the static library. While doing this, remove the SBJSON reference from one of the SDK.

这是我讨厌针对静态库进行构建的另一个原因.如果您没有源代码并且库制造商未在其类/方法前添加前缀,则该问题将无法解决.

This is another reason why I hate building against static libraries. The problem will be un-solveable if you don't have the source code and the library maker didn't prefix his classes/methods.

或者,您可以使用新发布的Facebook SDK 3.1版,在那里他们最终将SBJSON前缀为FBSBJSON.

Alternatively, you can use the newly released Facebook SDK, version 3.1, where they finally prefixed SBJSON to FBSBJSON.

这篇关于未定义符号和重复符号错误.可以针对调试或发布而构建,但不能同时针对两者进行构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆