Swift-->CocoaPods的使用与安装

前端之家收集整理的这篇文章主要介绍了Swift-->CocoaPods的使用与安装前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

很显然,你已经明白了CocoaPods是干啥的.
本文主要介绍CocoaPods在MAC OS X 10.11.6 的安装和使用.

CocoaPods开源首页:
https://github.com/CocoaPods/CocoaPods/
CocoaPods首页:
https://cocoapods.org/

1:通常都是使用pod install 安装依赖库@H_404_11@
pod install –verbose //详细模式安装
很不巧,pod command not found…WTF?

.
.
.
整理一下情绪,开始本文!

2:pod命令的安装@H_404_11@
如此简单的命令,太高兴了^_^…(这个命令执行可能会很慢哦~~~)

sudo gem install cocoapods


Error installing cocoapods:…WTF? 纳尼? 什么玩意? @#$%^&*()
查看当前ruby的版本 ruby -v:

.
.
.
重新整理一下情绪,让我们继续!

3:Ruby的更新(升级)@H_404_11@
Ruby官网: https://www.ruby-lang.org/en/downloads/
安装方法(各种系统的各种安装方法都有^_^):https://www.ruby-lang.org/en/documentation/installation/

apt (Debian or Ubuntu)@H_404_11@
Debian GNU/Linux and Ubuntu use the apt package manager. You can use it like this:

$ sudo apt-get install ruby-full@H_404_11@
As of writing,the ruby-full package provides Ruby 1.9.3,which is an old stable release,on Debian and Ubuntu.


yum (CentOS,Fedora,or RHEL)@H_404_11@
CentOS,and RHEL use the yum package manager. You can use it like this:

$ sudo yum install ruby@H_404_11@
The installed version is typically the latest version of Ruby available at the release time of the specific distribution version.


portage (Gentoo)@H_404_11@
Gentoo uses the portage package manager.

$ sudo emerge dev-lang/ruby@H_404_11@
By default,this will try to install versions 1.9 and 2.0,but more versions are available. To install a specific version,set RUBY_TARGETS in your make.conf. See the Gentoo Ruby Project website for details.


pacman (Arch Linux)@H_404_11@
Arch Linux uses a package manager named pacman. To get Ruby,just do this:

$ sudo pacman -S ruby@H_404_11@
This should install the latest stable Ruby version.


//我们选择 Homebrew (OS X) 这个家伙.@H_404_11@

Homebrew (OS X)@H_404_11@
On OS X El Capitan,Yosemite,and Mavericks,Ruby 2.0 is included. OS X Mountain Lion,Lion,and Snow Leopard ship with Ruby 1.8.7.

Many people on OS X use Homebrew as a package manager. It is really easy to get a newer version of Ruby using Homebrew:

$ brew install ruby@H_404_11@
This should install the latest Ruby version.

在命令行很兴奋的敲下命令:

brew install ruby


not found::: Oh……….尼玛,我艹!!! 顿时火冒三丈…
.
.
.
深呼吸,马上要到终点了!

4:brew命令的安装@H_404_11@
Homebrew就是brew,官网(中文的哦!!!):http://brew.sh/index_zh-cn.html
打开终端,粘贴回车…:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

查看版本brew -v:

终于顺利了一次,没有让宝宝失望.
.
.
.
高兴地向前走了一步!

5:更新Ruby@H_404_11@
宝宝不哭,这个过程更慢哦…喝杯茶,慢慢等.会好的.()

brew install ruby



要能访问: bintray.com 这个网站哦.

6:pod install@H_404_11@
请回到第一步…


Podfile 文件使用@H_404_11@
这是我的文件内容,仅供参考:

#source 'https://github.com/artsy/Specs.git'
source 'https://github.com/CocoaPods/Specs.git'
platform :ios,"8.0"

#Use frameworks instead of static libraries for Pods.
use_frameworks! #表示使用动态库的方式,否是使用静态库

#inhibit_all_warnings! #忽略所有警告
#workspace 'MyWorkspace' #指定工作区间
#pod #Specifies a dependency of the project.
#target 'WorkspaceTest' do

target 'space1' do
project './space1/space1.xcodeproj'
pod 'R.swift'
pod 'RxSwift'
pod 'RxCocoa'
pod 'Alamofire'
end

强烈建议你参考官网语法说明: https://guides.cocoapods.org/syntax/podfile.html#podfile


至此: 文章就结束了,如有疑问: QQ群 Android:274306954 Swift:399799363 欢迎您的加入.

猜你在找的Swift相关文章