CocoaPods安装及使用,小问题记录与解决

2020-03-31 20:47 来源:未知

原因:brew更新或重装的时候导致的我们电脑上没有ruby环境了,需要重新安装一下解决方案:安装ruby

卸载sass命令:

然后逐个删除吧:
$ sudo gem uninstall cocoapods-core
$ sudo gem uninstall cocoapods-downloader
etc...

ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj

$ sudo gem install cocoapods
Password:
etching: colored2-3.1.2.gem (100%)
Successfully installed colored2-3.1.2
Fetching: claide-1.0.2.gem (100%)
Successfully installed claide-1.0.2
Fetching: xcodeproj-1.5.0.gem (100%)
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/xcodeproj

解决方案

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

图片 1

$ brew remove git
$ brew remove curl
$ brew install openssl
$ brew install --with-openssl curl
$ brew install --with-brewed-curl --with-brewed-openssl git

[!] <PBXSourcesBuildPhase UUID=7DA7EFEB1FDA23A800B17618> attempted to initialize an object with an unknown UUID. 6124B2561FECCEB200077BCA for attribute: files. This can be the result of a merge and the unknown UUID is being discarded.

问题描述
同事pod新库之后合并代码,我这边拉下来之后重新pod install报错

图片 2

解决方法

  1. 选中 项目名称–>Target–>项目名称–>General–>Linked Frameworks and Libraries–>选中 libpods-项目名称.a 去除掉这个 .a
  2. 然后再一次 pod install
  3. 如果出现pod下面没有文件,就把Xcode关掉重新打开就好了
Updating rubygems-updateERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/update_rubygems

如果已经安装了ruby环境的话会有版本信息

1)运行sudo gem update --system报错

Updating installed gems Nothing to update

$ gem update cocoapod
Updating installed gems
Nothing to update

待解决


如果不确定电脑是否安装的ruby,可以打开终端输入以下命令查看:

解决办法:

ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/update_rubygems

$ sudo gem update --system
Password:
Updating rubygems-update
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/update_rubygems

解决方案
安装homebrew homebrew官网
然后安装ruby

$ brew install ruby

报错

Mac升级到 OSX 10.11 El Capitan 后中会出现错误:

问题2:

ERROR: While executing gem ... (OpenSSL::SSL::SSLError) hostname "upyun.gems.ruby-china.org" does not match the server certificate

$ gem update --system
Updating rubygems-update
ERROR:  While executing gem ... (OpenSSL::SSL::SSLError)
    hostname "upyun.gems.ruby-china.org" does not match the server certificate

解决方案

  • 在这里下载ruby源码点击下载,并解压
  • 安装openssl
$ brew install openssl

如果提示

Warning: openssl 1.0.2l is already installed

说明已经安装了openssl

  • cd到解压好的ruby源码文件夹中
  • 配置源码(此处需要添加openssl目录索引)
$ ./configure --with-openssl-dir=/usr/local/ssl
  • 编译ruby源码
$ make
  • 最后安装ruby
$ sudo make install

  1. 安装 Homebrew 一个Mac上用于管理命令行软件的工具

查找解决方案:

[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
  Cloning into 'master'...
  error: RPC failed; result=56, HTTP code = 200
  fatal: The remote end hung up unexpectedly
  fatal: early EOF
  fatal: index-pack failed

ERROR: While executing gem ... (Errno::EACCES) Permission denied - /Library/Ruby/Gems/2.0.0/gems/rubygems-update-2.6.7/.autotest

$ gem update --system
Updating rubygems-update
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied - /Library/Ruby/Gems/2.0.0/gems/rubygems-update-2.6.7/.autotest

解决方案

$ sudo gem update --system

 cd 任意的一个使用Git的项目 #执行 git repack --max-pack-size=500m -a -d pod setup

ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/update_rubygems

ruby环境准备好的话,接下来安装sass

其实在你安装CocoaPods执行pod install时,系统会默认操作pod setup,然而由于中国强大的墙可能会pod setup不成功。这时就需要手动执行pod setup指令,如下:

  • 终端输入:pod setup
    会出现Setting up CocoaPods master repo,稍等几十秒,最底下会输出Setup completed。说明执行pod setup成功。
  • 如果pod search操作还是搜索失败,如下:
    终端输入:pod search AFNetworking
    输出:Unable to find a pod with name, author, summary, or descriptionmatching 'AFNetworking'这时就需要继续下面的步骤了。

error: RPC failed; curl 56 SSLRead() return error -36

[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -36
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

解决方案

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

注意

  1. "/Applications/Xcode.app/Contents/Developer"此路径是当前默认XCode的所在位置,如果安装了多个XCode需要多加注意
  2. 做了以上操作之后还会报错,将XCode删除,重新安装

PS
获取当前XCode路径,在终端中输入

$ xcode-select --print-path

  • 运行

stackoverflow解决方案

Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -9806
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

error: RPC failed; curl 56 SSLRead() return error -9806

解决方案

$ git config --global http.postBuffer 524288000
$ pod setup

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

$ gem update sass

解决方案:

Unable to find a specification for "xxxx"

问题描述:
pod install时显示以下报错

图片 3

解决方法
更新一下repo,然后再install
更新repo的命令如下

pod repo update

rm -rf ~/.cocoapods/repospod setup

 [!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master Cloning into 'master'... error: RPC failed; result=56, HTTP code = 200 fatal: The remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed

检查sass命令:

2、安装指定版本的cocoapods
sudo gem install cocoapods --version 0.39.0

替换ruby源

$ gem sources
*** CURRENT SOURCES ***

http://rubygems-china.oss.aliyuncs.com

这个数据源已经失效了,我们移除掉

$ gem sources -r http://rubygems-china.oss.aliyuncs.com
http://rubygems-china.oss.aliyuncs.com removed from sources

加入新的数据源,目前只有ruby-china的源是保持更新的

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

确保当前只有一个ruby源

$ gem sources
*** CURRENT SOURCES ***

https://gems.ruby-china.org/

  1. 安装pod

$ gem uninstall sass

pod setup成功后,依然不能pod search,是因为之前你执行pod search生成了search_index.json,此时需要删掉。
终端输入:rm ~/Library/Caches/CocoaPods/search_index.json
删除成功后,再执行pod search
执行pod search
终端输入:pod search afnetworking(不区分大小写)
输出:Creating search index for spec repo 'master'.. Done!,稍等片刻······就会出现所有带有afnetworking字段的类库。

[!] The version of CocoaPods used to generate the lockfile (1.2.0) is higher than the version of the current executable (1.0.0). Incompatibility issues may arise.

$ pod install
Analyzing dependencies
[!] The version of CocoaPods used to generate the lockfile (1.2.0) is higher than the version of the current executable (1.0.0). Incompatibility issues may arise.

解决方案

$ sudo gem install cocoapods

 brew install ruby

更新sass命令:

cd 任意的一个使用Git的项目
   #执行
   git repack --max-pack-size=500m -a -d
   pod setup

出现: Performing a deep fetch of themasterspecs repo to improve future performance

使用如下命令重新安装:

5、cocoapods安装流程

 brew install ruby

在终端中输入:

4、先查看本地安装过的cocopods相关东西,命令如下:
$ gem list --local | grep cocoapods
会显示如下:

 sudo gem update --system

$ sudo gem install -n /usr/local/bin gem_package_name

1、更新指定的第三方库命令
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update

图片 4

cocoapods-core (0.39.0)
cocoapods-downloader (0.9.3)
cocoapods-plugins (0.4.2)
cocoapods-search (0.1.0)
cocoapods-stats (0.6.2)
cocoapods-trunk (0.6.4)
cocoapods-try (0.5.1)
  1. 安装ruby

$ sudo gem install sass

5)pod install库失败

sudo gem update --system

$ brew install ruby

[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master
Cloning into 'master'...
error: RPC failed; curl 56 SSLRead() return error -36
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

解决方案: 删除索引库,重新安装Pod,执行终端命令

图片 5

// 网址:http://brew.sh/
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. 更新 gem

没有安装ruby环境的话,接下来是安装步骤:

Updating rubygems-update
ERROR:  While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/update_rubygems
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

图片 6

  1. 执行pod setup

解决方案: 重新安装ruby

sass是基于ruby环境工作的,如果要正确安装sass,要确保你的电脑上安装了ruby。

4)pod search 搜索类库失败的解决办法

解决方案:

安装成功提示

rm -rf ~/.cocoapods/repos
pod setup

$ ruby -v

You can try adding it manually in ~/.cocoapods/repos or via pod repo add.
自己按照提示在终端输入以下命令:
pod repo add master https://github.com/CocoaPods/Specs.git
还是报错!
在终端输入以下命令:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developers
后面的地址你可以打开Xcode显示包内容,找到那个文件夹拖到终端里面。

安装时,已经是淘宝ruby环境,但是还是出现无法成功

  1. 查看ruby:ruby -v
  2. 查看源:gem sources -l
  3. 移除源:gem sources --remove https://rubygems.org/
  4. 设置新的源:gem sources -a https://ruby.taobao.org/
  5. 验证是否替换成功:gem sources -l
  6. 升级gem:sudo gem update --system
  7. 安装CocoaPods(OS X 10.11以前):sudo gem install cocoapods
  8. 安装CocoaPods(OS X 10.11以后):sudo gem install -n /usr/local/bin cocoapods
  9. pod setup(cd ~/.cocoapods/跳转到目录下用命令du -sh *查看下载进度)

$ sass -v

解决办法:

ruby信息

3、如果之前装过cocopods,最好先卸载掉,卸载命令:
$ sudo gem uninstall cocoapods

答主也说了,出现类似的错误提示,都可以用通用的命令试试可不可行。

原因:brew更新或重装的时候导致的我们电脑上没有ruby环境了,需要重新安装一下
解决方案:安装ruby:brew install ruby
安装Homebrew:

可以通过HomeBrew的方式安装ruby,在终端在输入:

  1. 删除~/Library/Caches/CocoaPods目录下的search_index.json文件

$ sudo gem install -n /usr/local/bin sass

6、cocoapods升级遇到的问题

2)执行pod update遇到的问题
出现:“Performing a deep fetch of themasterspecs repo to improve future performance”。
解决方案: 删除索引库,重新安装Pod,执行终端命令:

3)执行pod setup遇到的问题1
问题1:

TAG标签:
版权声明:本文由美高梅网投平台发布于美高梅网投网址,转载请注明出处:CocoaPods安装及使用,小问题记录与解决