问题描述
我正在尝试使用Xcode 6提供的新模板构建iOS框架(Test.framework)来创建Cocoa Touch Frameworks。
框架具有Podfile中指定的不同依赖关系(如AFNetworking或FacebookSDK)。我不希望依赖项包含在框架中,我只想链接它们。
I am trying to build an iOS Framework (Test.framework) using the new template offered by Xcode 6 for creating Cocoa Touch Frameworks.The framework has different dependencies (as AFNetworking or FacebookSDK) specified in a Podfile. I don't want dependencies to be included in the framework, I just want to link against them.
问题是当我构建框架时,libPods.a是链接和包括在内。
问:如何链接libPods.a库,但不包含在框架中?
The problem is that when I build the framework, the libPods.a is linked and included.Q: How can I link against libPods.a library, but not include it in the framework?
更多详情:
我读过有关弱链接的信息:
但是我没有太多玩项目设置的经验,所以我不是专业人士。
I have read about weak linking:https://developer.apple.com/library/ios/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.htmlBut I don't have much experience playing with project settings, so I'm a not a pro.
我试图将libPods.a作为可选但没有任何改变,仍然包含依赖项。
I tried to put libPods.a as an "Optional" but nothing changed, dependencies were still included.
我试图删除libPods.a Build Phases中的Link Binary With Libraries部分,但我收到此错误(清理项目文件夹并再次构建之后):
I tried to remove the libPods.a from the section "Link Binary With Libraries" in Build Phases, but I get this error (after cleaning project folder and building again):
ld: library not found for -lPods-MyFramework-AFNetworking
I试图从其他链接器标志中删除所有标志,但它给了我未定义的符号:
I tried to remove all the flags from "Other Linker Flags", but it gives me undefined symbols:
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_FBSession", referenced from:
objc-class-ref in TestClass.o
ld: symbol(s) not found for architecture armv7
以下是包含库的干净项目的源代码:
Here is the source code for a clean project with libraries included:https://www.dropbox.com/sh/0ymuzw6kiagz02j/AABzyHiZVaQQvBEnjBgRBq3ua?dl=0
推荐答案
我无法评论,所以我会在这里回答。
我想你不能这样做。 Cocoapods创建一个静态库而不是动态库,因此编译时所有代码都应该存在并嵌入到框架中。
I can not comment yet so I will answer here.I think you can not do that. Cocoapods create a static library not a dynamic one so all the code should be there when you compile and is embedded in your framework.
,请转到幕后发生了什么?详细解释
Cocoapods documentation, go to "What is happening behind the scenes?" for a detail explanation
如果您想为一些常用的pod设置一些基本配置,最好的方法是制作一个自定义的cocoapod与其他的一样依赖。这样您就可以依靠cocoapod来管理版本并根据您的偏好更新代码。我自己也使用类似的方法,我对结果非常满意。
If you want to put together some basic configuration for some of your usual pods probably the best way to go is making a custom cocoapod with the other ones as dependencies. That way you can rely in cocoapods to manage versions and have the code updated per your preferences. I am using a similar approach myself and I am quite happy with the results.
这篇关于如何使用弱链接的CocoaPods库构建iOS框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!