什么是Podfile呢?送给你来自官网的介绍
文章目錄
- 官網(wǎng)地址
- 什么是Podfile
- 遷移從0.x 到 1.0
- 指定pod版本
- 使用計(jì)算機(jī)本地文件夾中的文件。
- 從庫repo根目錄中的一個播客規(guī)范。
- 外部資源
- 寫在最后
官網(wǎng)地址
官網(wǎng)介紹
什么是Podfile
Podfile是描述一個或多個Xcode項(xiàng)目目標(biāo)的依賴關(guān)系的規(guī)范。該文件應(yīng)該簡單地命名為Podfile。指南中的所有示例都是基于CocoaPods 1.0及以上版本的。
一個Podfile可以非常簡單,這增加了一個單一的目標(biāo):
target 'MyApp' douse_frameworks!pod 'Alamofire', '~> 3.0' end一個更復(fù)雜的鏈接應(yīng)用程序和它的測試包的Podfile示例:
source 'https://github.com/CocoaPods/Specs.git' source 'https://github.com/Artsy/Specs.git'platform :ios, '9.0' inhibit_all_warnings!target 'MyApp' dopod 'GoogleAnalytics', '~> 3.1'# Has its own copy of OCMock# and has access to GoogleAnalytics via the app# that hosts the test targettarget 'MyAppTests' doinherit! :search_pathspod 'OCMock', '~> 2.0.1'end endpost_install do |installer|installer.pods_project.targets.each do |target|puts target.nameend end如果希望多個目標(biāo)共享相同的pods,請使用***abstract_target***。
# There are no targets called "Shows" in any Xcode projects abstract_target 'Shows' dopod 'ShowsKit'pod 'Fabric'# Has its own copy of ShowsKit + ShowWebAuthtarget 'ShowsiOS' dopod 'ShowWebAuth'end# Has its own copy of ShowsKit + ShowTVAuthtarget 'ShowsTV' dopod 'ShowTVAuth'end end有隱式抽象目標(biāo)在根的Podfile,所以你可以寫上面的例子:
pod 'ShowsKit' pod 'Fabric'# Has its own copy of ShowsKit + ShowWebAuth target 'ShowsiOS' dopod 'ShowWebAuth' end# Has its own copy of ShowsKit + ShowTVAuth target 'ShowsTV' dopod 'ShowTVAuth' end遷移從0.x 到 1.0
我們有一篇博客文章詳細(xì)解釋了這些變化。
指定pod版本
在開始一個項(xiàng)目時,您可能希望使用最新版本的Pod。如果是這種情況,只需忽略版本需求。
pod 'SSZipArchive'稍后在項(xiàng)目中,您可能希望凍結(jié)到某個Pod的特定版本,在這種情況下,您可以指定該版本號。
pod 'Objection', '0.9'除了沒有版本或特定的版本之外,還可以使用邏輯操作符:
- ‘> 0.1’ Any version higher than 0.1(’> 0.1’任何高于0.1的版本)
- ‘>= 0.1’ Version 0.1 and any higher version(’>= 0.1’版本0.1和任何更高版本)
- ‘< 0.1’ Any version lower than 0.1(’< 0.1’小于0.1的任何版本)
- ‘<= 0.1’ Version 0.1 and any lower version(’<= 0.1’版本0.1和任何更低的版本)
CocoaPods除了邏輯運(yùn)算符外,還有一個樂觀運(yùn)算符~>:
- ‘~> 0.1.2’ Version 0.1.2 and the versions up to 0.2, not including 0.2 and higher(’~> 0.1.2’版本0.1.2和0.2以內(nèi)的版本,不包括0.2及以上版本)
- ‘~> 0.1’ Version 0.1 and the versions up to 1.0, not including 1.0 and higher(’~> 0.1’版本0.1和版本到1.0,不包括1.0和更高)
- ‘~> 0’ Version 0 and the versions up to 1.0, not including 1.0 and higher(’~> '版本0和版本到1.0,不包括1.0和更高)
有關(guān)版本控制策略的更多信息,請參見:
-
Semantic Versioning(語義版本控制)
-
RubyGems Versioning Policies(RubyGems版本管理策略)
-
谷歌有一個很棒的視頻介紹了它是如何工作的:(天朝不翻墻打不開 - -!) “CocoaPods and the Case of the Squiggly Arrow (Route 85)”.
-
注意,視頻中關(guān)于~> 1的信息是不正確的。
使用計(jì)算機(jī)本地文件夾中的文件。
如果您想要開發(fā)一個Pod及其客戶端項(xiàng)目,您可以使用:path。
pod 'Alamofire', :path => '~/Documents/Alamofire'使用這個選項(xiàng),CocoaPods將假定給定的文件夾是Pod的根目錄,并將從那里直接鏈接到Pods項(xiàng)目中的文件。這意味著您的編輯將在安裝CocoaPods期間保持。引用的文件夾可以是您最喜歡的SCM的簽出,甚至是當(dāng)前repo的git子模塊。
請注意,Pod文件的podspec應(yīng)該在指定的文件夾中。
從庫repo根目錄中的一個播客規(guī)范。
有時你可能想要使用一個Pod的前沿版本,一個特定的修訂或你自己的叉子。如果是這種情況,您可以通過pod聲明來指定。
回購主分支的使用:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git'使用回購的不同分支:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :branch => 'dev'使用回購的標(biāo)簽:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :tag => '3.1.1'或指定提交:
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire.git', :commit => '0f506b1c45'但需要注意的是,這意味著該版本必須滿足其他Pod對Pod的任何其他依賴。
這個podspec文件應(yīng)該在repo的根目錄中,如果這個庫的repo中還沒有一個podspec文件,那么您將不得不使用下面部分中列出的方法之一。
外部資源
- Non-trivial Podfile in
Artsy/Eigen(非平凡的Podfile在藝術(shù)/特征) - Podfile for a Swift project in
Artsy/Eidolon(在一個Swift項(xiàng)目的播客文件藝術(shù)/的精靈)
寫在最后
首頁/使用Podfile/Podfile
CocoaPods是開源項(xiàng)目通過發(fā)送一個pull request來幫助我們改進(jìn)這些指南
總結(jié)
以上是生活随笔為你收集整理的什么是Podfile呢?送给你来自官网的介绍的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matlab生成正交试验,正交表的构造方
- 下一篇: LDA算法入门