我在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-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 编写.
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 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!