Cocoapods安装

1.设置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命令执行后会出现:Setting up CocoaPods master repo ,稍等就好,完成时出现 Setup completed查看pod版本:pod --version

3.编辑podfile

$ vim Podfile

以下是swift项目:

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: 相关操作,i 编辑模式,esc 停止编辑,:wq 保存并退出

$ pod install

注:mac升级到10.12后pod不能用先执行

显示:-bash: pod: command not found

先执行:sudo gem install -n /usr/local/bin cocoapods

参考:http://www.jianshu.com/p/4ef582835e89

你可能感兴趣的:(Cocoapods安装)