1.設(shè)置ruby源
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
PS:淘寶的鏡像源由之前的http://ruby.taobao.org/,改為https://ruby.taobao.org/
2.下載安裝
PS: 如果之前安裝了0.39.0,1.0.0.beta.2,又升級不了,可以 $ gem cleanup 清除之前所有版本
$ sudo gem install cocoapods -v 1.0.0.beta.6
$ pod setup
PS:setup命令執(zhí)行后會(huì)出現(xiàn):Setting up CocoaPods master repo ,稍等就好,完成時(shí)出現(xiàn) Setup completed查看pod版本:
pod --version
3.編輯podfile
$ vim Podfile
以下是swift項(xiàng)目:
source 'https://github.com/CocoaPods/Specs.git'
# Required for Swift apps
platform :ios, '8.0'
use_frameworks!
# The target name is most likely the name of your project.
target 'nongbangzhu' do
# Your 'node_modules' directory is probably in the root of your project,
# but if not, adjust the `:path` accordingly
pod 'React', :path => '../node_modules/react-native', :subspecs => [
'Core',
'RCTText',
'RCTImage’,
'RCTNetwork’,
'RCTLinkingIOS’,
'RCTWebSocket', # needed for debugging
# Add any other subspecs you want to use in your project
]
end
PS: 相關(guān)操作,i 編輯模式,esc 停止編輯,:wq 保存并退出
$ pod install
注:mac升級到10.12后pod不能用先執(zhí)行
顯示:-bash: pod: command not found
先執(zhí)行:sudo gem install -n /usr/local/bin cocoapods