简体   繁体   English

包含另一个框架的Swift Cocoa Touch Framework

[英]Swift Cocoa Touch Framework containing another Framework

I'm trying to build a framework that implements a REST API which I want to reuse and share. 我正在尝试构建一个实现REST API的框架,我想重用和共享。 To handle the network access, I want to use Alamofire inside this API framework. 为了处理网络访问,我想在这个API框架中使用Alamofire。 Everything works so far except that my test app, which actually uses my API framework, won't build because Alamofire is missing. 到目前为止一切都有效,除了我的测试应用程序实际上使用我的API框架,因为Alamofire缺失而无法构建。

In the app's target I can set "Embedded Binaries" to include my API Framework. 在应用程序的目标中,我可以设置“嵌入式二进制文件”以包含我的API框架。 If I also include Alamofire there, it works. 如果我在那里也包括Alamofire,那就有效。

Now I wonder if there is a way to put the Alamofire framework into my API framework so that the app only has to include one framework. 现在我想知道是否有办法将Alamofire框架放入我的API框架中,以便应用程序只需要包含一个框架。 The API framework's target->general settings don't have the section "Embedded Binaries". API框架的target-> general设置没有“Embedded Binaries”部分。 But maybe this can be done in another way. 但也许这可以用另一种方式完成。 Or is this not a good approach at all? 或者这根本不是一个好方法?

Thanks for your help! 谢谢你的帮助!

--- UPDATE --- ---更新---

Of course it is possible to add the source files of the Alamofire framework in my API framework. 当然可以在我的API框架中添加Alamofire框架的源文件。 This way my app only has to import the API framework. 这样我的应用程序只需要导入API框架。 But I still wonder if it's possible to include the Alamofire framework in my API framework. 但我仍然想知道是否可以在我的API框架中包含Alamofire框架。

Half a year later I learned that this is simply not meant to work this way in Xcode with iOS frameworks. 半年后,我了解到这并不意味着在Xcode和iOS框架中以这种方式工作。 If a framework depends on other 3rd party frameworks, you need to import those frameworks into your own target. 如果框架依赖于其他第三方框架,则需要将这些框架导入到您自己的目标中。 I'm using Xcode 8 beta 3 and nothing changed so far and probably won't in the future. 我正在使用Xcode 8 beta 3,到目前为止没有任何改变,将来可能不会。

I think the reason is simple: If the above would be possible, you could end up having one framework included several times in your project, because some of your frameworks include other frameworks include other frameworks include other frameworks include other frameworks include other frameworks... 我认为原因很简单:如果以上是可能的,你最终可能会在项目中多次包含一个框架,因为你的一些框架包括其他框架包括其他框架包括其他框架包括其他框架包括其他框架.. 。

I think you get the point :P 我想你明白了:P

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM