2017年cocoaPods 1.2.1升级


还在用老版本的ccoaPods,安装三方库时,会报错 :

[!] Invalid `Podfile` file: [!] The specification of `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、添加国内最新的源。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索引文件,创建本地索引库(这里要多等一会儿)

pod setup

 

8、进入项目目录

cd ~

 

9.创建Podfile文件 (编写Podfile文件也是一个注意点,主要一点是项目有多个target)

  情况一:多个target公用相同库,还可以添加额外的不同第三方库.

# -*- coding: UTF-8 -*- source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.0' # ruby语法 # target数组 如果有新的target直接加入该数组 targetsArray = ['targetName1', 'targetName2', 'targetName3', 'targetName4', 'targetName5'] # 循环 targetsArray.each do |t| target t do 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' end target 'targetName2' do pod 'MJRefresh', '~> 1.4.6' pod 'Masonry', '~> 0.6.1' pod 'AFNetworking', '~> 3.0' end


参考来自:

http://www.cnblogs.com/Crazy-D/p/6421611.html http://www.jianshu.com/p/5d29bc212273


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM