還在用老版本的ccoaPods,安裝三方庫時,會報錯 :
[!] Invalid `Podfile` file: [!] The specificationof `link_with`in the Podfile is now unsupported, please use target blocks instead..
所以得升級cocoaPods到1.2.1最新版
安裝源:
1、查看ruby源
gem sources -l
2、移除掉原有的源
gem sources --remove https://rubygems.org/
3、添加國內(nèi)最新的源。ruby-china
gem sources -a https://gems.ruby-china.org
4、檢查是否添加成功
gem sources -l
5、安裝cocoapods
sudo gem install -n /usr/local/bin cocoapods
6、安裝完成后查看pod版本
pod --version
7、更新Podspec索引文件,創(chuàng)建本地索引庫(這里要多等一會兒)
pod setup
8、進入項目目錄
cd ~
9.創(chuàng)建Podfile文件 (編寫Podfile文件也是一個注意點,主要一點是項目有多個target)
情況一:多個target公用相同庫,還可以添加額外的不同第三方庫.
# -*- coding: UTF-8 -*-source'https://github.com/CocoaPods/Specs.git'platform:ios,'8.0'
# ruby語法
#target數(shù)組?
如果有新的target直接加入該數(shù)組targetsArray = ['targetName1','targetName2','targetName3','targetName4','targetName5']
# 循環(huán)targetsArray.eachdo|t|? ?
?target tdo? ? ? ?
?pod'MJRefresh','~> 1.4.6'? ? ??
? pod'Masonry','~> 0.6.1'
end
end
情況二:當項目只有一個target
source'https://github.com/CocoaPods/Specs.git'platform :ios,'8.0'
target'targetName1'do? ?
?pod'MJRefresh','~> 1.4.6'? ??
pod'Masonry','~> 0.6.1'
end
情況三:不同target依賴庫
source'https://github.com/CocoaPods/Specs.git'platform :ios,'8.0'
target'targetName1'
do? ? pod'MJRefresh','~> 1.4.6'? ??
pod'Masonry','~> 0.6.1'endtarget'targetName2'do? ??
pod'MJRefresh','~> 1.4.6'? ? pod'Masonry','~> 0.6.1'? ??
pod'AFNetworking','~> 3.0'
end