为什么我们在CocoaPods中使用use_frameworks? [英] Why do we use use_frameworks in CocoaPods?

查看:602
本文介绍了为什么我们在CocoaPods中使用use_frameworks?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CocoaPods Podfile 中多次使用 use_frameworks 。我只是想知道为什么要使用它?我无法得到它的直接答案。

I have used use_frameworks in CocoaPods Podfile many times. I just wonder why do we use it? I couldn't get the straight forward answer of it.

示例:

platform :ios, '8.0'
use_frameworks!

target "CityWhether" do
    pod 'Alamofire'
    pod 'SwiftyJSON'
end


推荐答案

use_frameworks 告诉CocoaPods您要使用Frameworks而不是Static Libraries。由于Swift不支持静态库,您必须使用框架。

use_frameworks tells CocoaPods that you want to use Frameworks instead of Static Libraries. Since Swift does not support Static Libraries you have to use frameworks.

在另一个答案中,我解释了静态库之间的区别和框架:

In another answer, I explained the differences between Static Libraries and Frameworks:


Cocoa Touch框架



它们始终是开源的,将像您的应用程序一样构建。 (所以
Xcode有时会编译它,当你运行你的应用程序时,在你清理项目后总是
。)框架只支持iOS 8和
更新,但你可以使用Swift和Objective-框架中的C.

Cocoa Touch Frameworks

They are always open-source and will be built just like your app. (So Xcode will sometimes compile it, when you run your app and always after you cleaned the project.) Frameworks only support iOS 8 and newer, but you can use Swift and Objective-C in the framework.

顾名思义,它们是静态的。因此,当你将
导入项目时,它们已经编译好了。您可以与他人分享
而不向他们展示您的代码。请注意,静态库目前
不支持Swift。您必须在
库中使用Objective-C。应用程序本身仍然可以用Swift编写。

As the name says, they are static. So they are already compiled, when you import them to your project. You can share them with others without showing them your code. Note that Static Libraries currently don't support Swift. You will have to use Objective-C within the library. The app itself can still be written in Swift.

来源:我的其他答案 | AddThis.com博客

这篇关于为什么我们在CocoaPods中使用use_frameworks?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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