CocoaPods的Podfile文件編寫(xiě)


一、Podfile文件??

platform :ios,'7.0'
# 去掉來(lái)自cocoapods的所有警告
inhibit_all_warnings!
def commonPods
    pod 'AFNetworking', '~> 2.5.0'
    pod 'SDWebImage', '~> 3.7.1'
    pod 'YYModel', '~> 1.0.4'
    pod 'UEKFoundation', :git => 'https://github.com/yangyongzheng/UEKFoundation.git'
end
target 'TestApp' do
    commonPods
end
target 'TestAppTests' do
    inherit! :search_paths
end

二、Podfile語(yǔ)法參考

Podfile Syntax Reference官網(wǎng)

1)永遠(yuǎn)使用最新版:pod 'YYModel'

2)使用固定版本:pod 'YYModel', '1.0.4'

3)操作符:

  • = 0.1 Version 0.1.
  • > 0.1 Any version higher than 0.1.
  • >= 0.1 Version 0.1 and any higher version.
  • < 0.1 Any version lower than 0.1.
  • <= 0.1 Version 0.1 and any lower version.
  • ~> 0.1.2 Version 0.1.2 and the versions up to 0.2, not including 0.2. This operator works based on the last component that you specify in your version requirement. The example is equal to >= 0.1.2 combined with < 0.2.0 and will always match the latest known version matching your requirements.

三、workspace多工程聯(lián)編Podfile文件編寫(xiě)

# 多工程聯(lián)編Podfile文件配置
workspace 'YZWorkSpace'     # 需要生成的workspace的名稱
# project 'path' 指定包含Pods庫(kù)應(yīng)鏈接的目標(biāo)的Xcode項(xiàng)目,其中path為項(xiàng)目鏈接的路徑
# 對(duì)于1.0之前的版本,請(qǐng)使用xcodeproj
project 'YZToolsLib/YZToolsLib' # 工具庫(kù)工程
project 'YZToolsDemo/YZToolsDemo'   # 實(shí)例工程
platform :ios, '7.0'
inhibit_all_warnings!   # 禁止CocoaPods庫(kù)中的所有警告。
def commonPods
    pod 'FMDB'
end
# This Target can be found in a Xcode project called `ToolsSDK`
# 工具庫(kù)工程需要引入的第三方庫(kù)
target 'YZToolsLib' do
    project 'YZToolsLib/YZToolsLib'
    commonPods
end
# Same Podfile, multiple Xcodeprojects
# 實(shí)例工程需要引入的第三方庫(kù)
target 'YZToolsDemo' do
    project 'YZToolsDemo/YZToolsDemo'
    commonPods
end

項(xiàng)目目錄結(jié)構(gòu)樹(shù)如下:


多工程聯(lián)編項(xiàng)目目錄結(jié)構(gòu)樹(shù).png

注:tree -L N這個(gè)命令,只查看當(dāng)前第N級(jí)的目錄和文件。

  • 此命令需要安裝tree,安裝命令:brew install tree。
  • 安裝brew命令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容