ReactNative 安装cocoapods

2016-11-09  本文已影响118人  滕的世界

React Native使用cocoapods

安装步骤:

1.安装ruby 并升级

ruby -v
gem sources --remove https://rubygems.org/ 
gem sources -a http://ruby.taobao.org/ 

用来检查使用替换镜像位置成功

gem sources -l  
https://gems.ruby-china.org
这个是ruby的官方源码,现在国内可以使用的还有以下ruby源
https://ruby.taobao.org/   淘宝源
http://rubygems-china.oss.aliyuncs.com 阿里云源

2.安装cocoapods

查看安装详细过程,添加-V参数,查看安装过程

sudo gem install cocoapods -V

3.升级工程

vim Podfile
platform :ios, '8.0'
target '你的项目名称' do
pod 'AFNetworking', '~> 3.0'
end
pod install

安装过程的BUG和详细参考:

1.安装cocoapods失败: Operation not permitted

 (Errno::EPERM) *Operation* *not* *permitted* - */usr/bin/xcodeproj* 

可尝试如下命令:

sudo gem install -n /usr/local/bin cocoapods

2.cocoapods的配置细节:

pod 'AFNetworking'      //不显式指定依赖库版本,表示每次都获取最新版本    
pod 'AFNetworking', '2.0'     //只使用2.0版本    
pod 'AFNetworking', '> 2.0'     //使用高于2.0的版本    
pod 'AFNetworking', '>= 2.0'     //使用大于或等于2.0的版本    
pod 'AFNetworking', '< 2.0'     //使用小于2.0的版本    
pod 'AFNetworking', '<= 2.0'     //使用小于或等于2.0的版本    
pod 'AFNetworking', '~> 0.1.2'     //使用大于等于0.1.2但小于0.2的版本    
pod 'AFNetworking', '~>0.1'     //使用大于等于0.1但小于1.0的版本    
pod 'AFNetworking', '~>0'     //使用最新版本,与不显示指定依赖库版本相同 

举个例子:

# Uncomment the next line to define a global platform for your project
platform :ios, ‘8.0’

target 'together' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
  #react-native-image-crop-picker
  pod 'RSKImageCropper' , '1.5.2'
  pod 'QBImagePickerController' , '3.4.0'
  
  # Pods for together

  target 'togetherTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

cocoapods使用方法参考:

上一篇 下一篇

猜你喜欢

热点阅读