iOS安装CocoaPods详细过程

安装CocoaPods必须先安装Ruby环境

一:升级Ruby环境

gem update --system

二:更换Ruby镜像

gem sources -a https://gems.ruby-china.com/

gem sources -a https://gems.ruby-china.org/   #已不可用

检查镜像,出现下图,ruby镜像安装成功。

gem sources -l


三:安装CocoaPods

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

出现报错如下,说明ruby环境版本低
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.

我的当前是:2.3.7,更新至2.6,如下图

rvm install ruby-2.6

设置ruby2.6为默认镜像,再次安装cocoapods即可

rvm use ruby-2.6.5

rvm --default use 2.6.5

platform :ios, '9.0'

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'

use_frameworks!

target '项目名' do

  pod 'AFNetworking','~> 4.0.1'

  pod 'SVProgressHUD', '~> 2.2.5'

  pod 'JSONModel'

  pod 'MJRefresh'

  pod 'SDWebImage'

  pod 'HBDNavigationBar'

  pod 'MBProgressHUD', '~> 1.1.0'

  pod 'DateTools'

  pod 'WZLBadge'

  pod 'Masonry'

  pod 'MJExtension'

  pod 'RTRootNavigationController'

  pod 'CRBoxInputView'

  pod 'SDCycleScrollView','>= 1.80'

  pod 'CWLateralSlide'

  pod 'FMDB'

#  pod 'Bugly'

  pod 'YYModel'

  pod 'YYKit'

end

你可能感兴趣的:(iOS安装CocoaPods详细过程)