Xcode多个静态库和重复的符号 [英] Xcode Multiple Static Libraries and Duplicate Symbols

查看:324
本文介绍了Xcode多个静态库和重复的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个依赖于两个静态实用程序库(libBFSDK& libBetfair-Platform)的iPad应用程序。两个静态库都包括AFNetworking。当我尝试在我的iPad应用程序中包含两个静态库时,我收到如下链接错误:

I'm developing an iPad application which relies on two static utility libraries (libBFSDK & libBetfair-Platform). Both static libraries include AFNetworking. When I try to include the two static libraries in my iPad application, I get a linking error like:

duplicate symbol _OBJC_METACLASS_$_AFImageCache in:
/Users/osheas/Library/Developer/Xcode/DerivedData/Betfair-gnnjnwtovdmtoxakuxbjyvetciyy/Build/Products/Debug-iphonesimulator/libBFSDK.a(UIImageView+AFNetworking.o)
/Users/osheas/Library/Developer/Xcode/DerivedData/Betfair-gnnjnwtovdmtoxakuxbjyvetciyy/Build/Products/Debug-iphonesimulator/libBetfair-Platform.a(UIImageView+AFNetworking.o)
ld: 86 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

UIImageView + AFNetworking是AFNetworking的一部分。两个静态库都包括AFNetworking。因此,我获得了UIImageView + AFNetworking的重复符号。

UIImageView+AFNetworking is part of AFNetworking. Both static libraries include AFNetworking. As a result, I get duplicate symbols for UIImageView+AFNetworking.

任何人都有关于此解决方法的想法?我可以访问两个静态库的源代码,但我仍然不确定如何解决这个问题。

Anyone have ideas on a workaround for this? I have access to the source code for the two static libraries, but I'm still not sure how to solve this problem.

谢谢&如果您需要任何其他详细信息,请告诉我。

Thanks & please let me know if you need any other details,

Sean

PS - FWIW我正在运行Xcode 4.5&我需要能够部署到iOS 4.x设备。

PS - FWIW I'm running Xcode 4.5 & I need to be able to deploy to iOS 4.x devices.

推荐答案

因为您可以访问静态库的源代码,您可以使用预处理器将AFNetworking符号重命名为唯一的。

Since you have access to the source for the static libs, you could use the preprocessor to rename the AFNetworking symbols to something unique.

将每个重复符号的标记添加到Other C Flags构建设置中,格式为

Add flags for each duplicate symbol to your "Other C Flags" build setting with the format

-AFNetworkingSymbol = UniqueAFNetworkingSymbol

这仍将导致重复的代码,但应该允许您拥有AFNetworking的多个副本而无需修改源。

This will still result in duplicate code, but should allow you to have multiple copies of AFNetworking without modifying the source.

更多信息

理想情况下,大多数开源的Obj-C代码将转移到像CocoaPods这样的解决方案,只需指定依赖项而不是捆绑它们。

Ideally, most open source Obj-C code will move to solutions like CocoaPods and just specify dependencies instead of bundling them.

这篇关于Xcode多个静态库和重复的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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