一、Podfile文件??
platform :ios,'7.0'
# 去掉來自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語法參考
1)永遠使用最新版: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多工程聯編Podfile文件編寫
# 多工程聯編Podfile文件配置
workspace 'YZWorkSpace' # 需要生成的workspace的名稱
# project 'path' 指定包含Pods庫應鏈接的目標的Xcode項目,其中path為項目鏈接的路徑
# 對于1.0之前的版本,請使用xcodeproj
project 'YZToolsLib/YZToolsLib' # 工具庫工程
project 'YZToolsDemo/YZToolsDemo' # 實例工程
platform :ios, '7.0'
inhibit_all_warnings! # 禁止CocoaPods庫中的所有警告。
def commonPods
pod 'FMDB'
end
# This Target can be found in a Xcode project called `ToolsSDK`
# 工具庫工程需要引入的第三方庫
target 'YZToolsLib' do
project 'YZToolsLib/YZToolsLib'
commonPods
end
# Same Podfile, multiple Xcodeprojects
# 實例工程需要引入的第三方庫
target 'YZToolsDemo' do
project 'YZToolsDemo/YZToolsDemo'
commonPods
end
項目目錄結構樹如下:
多工程聯編項目目錄結構樹.png
注:
tree -L N
這個命令,只查看當前第N級的目錄和文件。
- 此命令需要安裝
tree
,安裝命令:brew install tree
。- 安裝
brew
命令:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"