为什么我们使用use_frameworks!在CocoaPods中? [英] Why do we use use_frameworks! in CocoaPods?
问题描述
我在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您要使用框架而不是静态库。由于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:
可可触摸框架
它们始终是开源的,并且会像您的应用程序一样构建。 (因此
Xcode有时会在运行应用程序时进行编译,并且在清理项目后始终会编译
。)框架仅支持iOS 8和
,但您可以使用Swift和Objective-
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博客
这篇关于为什么我们使用use_frameworks!在CocoaPods中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!