CocoaPod的安装

news/2024/7/20 20:36:19 标签: CocoaPod, iOS, swift, gem, ruby

更新以前大家都是根据淘宝镜像来安装cocoapods,此篇文章也和大多数博文内容相仿。后来换电脑时,同事说淘宝镜像已经不能用了,网上又重新查看教程,确实都是这么说的!(好吧,我确实比较懒,都没有按照之前步骤去试一下)

1.有人说需要升级ruby

参考链接:爱敲代码的兔子---> iOS极速安装CocoaPods详细教程 

gem update --system  ===> ERROR

详细信息如下:

 

Updating rubygems-update

Fetching: rubygems-update-2.6.7.gem (100%)

Successfully installed rubygems-update-2.6.7

Parsing documentation for rubygems-update-2.6.7

Installing ri documentation for rubygems-update-2.6.7

Installing darkfish documentation for rubygems-update-2.6.7

Parsing documentation for rubygems-update-2.6.7

Installing RubyGems 2.6.7

ERROR:  While executing gem ... (Errno::EACCES)

    Permission denied - /Library/Ruby/Site/2.0.0/rubygems/basic_specification.rb

或者 sudo gem update --system  ===> ERROR

详细信息如下:

 

Updating rubygems-update

Fetching: rubygems-update-2.6.7.gem (100%)

ERROR:  While executing gem ... (Errno::EPERM)

    Operation not permitted - /usr/bin/update_rubygems

bobbobbob:~ apple$ sudo gem update --system

Updating rubygems-update

ERROR:  While executing gem ... (Errno::EPERM)

    Operation not permitted - /usr/bin/update_rubygems

解决上述Operation not permitted,使用sudo gem update -n /usr/local/bin --system

 

2.安装使用,gem install cocoapods

 

 

ERROR:  While executing gem ... (Gem::FilePermissionError)

    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

或者,sudo gem install cocoapods

 

ERROR:  While executing gem ... (Errno::EPERM)

    Operation not permitted - /usr/bin/xcodeproj

解决上述Operation not permitted,使用sudo gem install -n /usr/local/bin cocoapods ===> ERROR

参考链接:http://stackoverflow.com/questions/30812777/cannot-install-cocoa-pods-after-uninstalling-results-in-error/30851030#30851030

详细信息如下:

 

Successfully installed xcodeproj-1.4.2

Fetching: ruby-macho-0.2.6.gem (100%)

Successfully installed ruby-macho-0.2.6

Fetching: molinillo-0.5.7.gem (100%)

Successfully installed molinillo-0.5.7

Fetching: cocoapods-trunk-1.1.2.gem (100%)

Successfully installed cocoapods-trunk-1.1.2

Fetching: cocoapods-downloader-1.1.3.gem (100%)

Successfully installed cocoapods-downloader-1.1.3

Fetching: cocoapods-core-1.2.0.gem (100%)

Successfully installed cocoapods-core-1.2.0

Fetching: cocoapods-1.2.0.gem (100%)

ERROR:  While executing gem ... (TypeError)

    no implicit conversion of nil into String

解决上述no implicit conversion of nil into String,ruby需要升级,重复1的操作。

3.使用sudo gem install cocoapods --pre ===> ERROR

详细信息如下:

 

Fetching: colored2-3.1.2.gem (100%)

Successfully installed colored2-3.1.2

Fetching: cocoapods-core-1.2.1.beta.1.gem (100%)

Successfully installed cocoapods-core-1.2.1.beta.1

Fetching: cocoapods-1.2.1.beta.1.gem (100%)

ERROR:  While executing gem ... (Errno::EPERM)

    Operation not permitted - /usr/bin/pod

4.如步骤2的错误,使用sudo gem install -n /usr/local/bin cocoapods --pre

详细信息如下:

……
……
21 gems installed

然后pod install --verbose --no-repo-update安装,若出现以下问题:

[!] You need at least git version 1.8.5 to use CocoaPods (Pod::Informative)

有一种可能是cocoapods安装成功了,但是链接Xcode的版本过低,所以需要更新Xcode。或者你电脑安装了多个版本的Xcode,就需要修改链接Xcode路径,改成链接电脑比较高版本的Xcode。
修改链接命令是:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
后面的路径根据你较高版本Xcode路径修改(只要把所需链接的xcode拖入终端就可以获取到了)。

安装步骤:

  • 1.移除原ruby镜像源

 

gem sources --remove https://rubygems.org/

 

  • 2.新增镜像源

 

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

 

  • 3.查看你的Ruby镜像

 

gem sources -l

终端出现如下图所示,第三步成功

4.看来Ruby版本还可以,镜像安装成功。

小插曲:此时我以为cocoapods已安装,就使用 pod install ,详细信息如下:

 

/Library/Ruby/Site/2.0.0/rubygems.rb:254:in `bin_path': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)

from /usr/local/bin/pod:22:in `<main>'

5.如果之前安装过cocoapods,使用sudo gem uninstall cocoapods

6.安装cocoapods,使用gem install cocoapods

小插曲:此时我想cocoapods已安装,就使用 pod install ,详细信息如下:

[!] No `Podfile' found in the project directory.

原因:笨啊,没有Podfile文件啊。

7.如何使用将会在下一篇文章中详细介绍。

 

CocoaPod的使用


http://www.niftyadmin.cn/n/704466.html

相关文章

CocoaPod的使用

CocoaPod的安装 安装CocoaPods成功之后&#xff0c;首先会找一些第三方库以及最新版本&#xff08;要知道想用什么库才能搜索&#xff09; 1.寻找第三方库是否存在&#xff0c;以及版本 &#xff08;Masonry是第三方库名称&#xff09; pod search Masonry 2.使用cd 指令&a…

Python读取大文件的坑“与内存占用检测

python读写文件的api都很简单&#xff0c;一不留神就容易踩”坑“。笔者记录一次踩坑历程&#xff0c;并且给了一些总结&#xff0c;希望到大家在使用python的过程之中&#xff0c;能够避免一些可能产生隐患的代码。1.read()与readlines()&#xff1a; 随手搜索python读写文件的…

iOS 获取系统当前时间

获取系统当前时间&#xff1a; NSDate *currentDate[NSDate date];NSDateFormatter *dateformatter[[NSDateFormatter alloc]init];[dateformatter setDateFormat:"YYYY-MM-dd HH:mm:ss"];NSString *currentTime[dateformatter stringFromDate:currentDate];NSLog(&q…

同服务器 内的 不同数据库对象之间的对比

以下 SQL 只适用于 同服务器 内的 不同数据库 之间的对比&#xff0c;如果是不同的服务器&#xff0c;可以把 服务器A 中的目标数据库备份后&#xff0c;以另一个名字恢复到 服务器B 中 1、u表&#xff0c;p存储过程&#xff0c;v视图 的存在性对比1&#xff09;表sysobjects.u…

iOS开发系列--数据存取

数据存取 http://www.cnblogs.com/kenshincui/p/4077833.html 概览 在iOS开发中数据存储的方式可以归纳为两类&#xff1a;一类是存储为文件&#xff0c;另一类是存储到数据库。例如前面 IOS开发系列—Objective-C之Foundation框架 的文章中提到归档、plist文件存储&#xf…

微服务架构的核心要点和实现原理解析

摘要&#xff1a;本文中&#xff0c;我们将进一步理解微服务架构的核心要点和实现原理&#xff0c;为读者的实践提供微服务的设计模式&#xff0c;以期让微服务在读者正在工作的项目中起到积极的作用。微服务架构中职能团队的划分传统单体架构将系统分成具有不同职责的层次&…

UITextField 的使用

1.UITextField 的基本设置 UITextField *passTf [[UITextField alloc]init];//初始化passTf.placeholder "密码";//填充背景提示passTf.secureTextEntry YES; //设置为密码格式&#xff0c;默认是明文格式passTf.delegate self;//设置代理&#xff0c;能够使用协…

记录 HtmlHelper和 强类型页面

HtmlHelper 路径生成<!--普通写法--> <a href"/home/index">超链接</a> <!--利用Url类动态--> <a href"Url.Action("index","home")">超链接</a> <!--利用HtmlHelper生成--> Html.ActionL…