美文网首页带我飞程序员iOS开发
轻松几步搞定CocoaPods持续更新中。。。

轻松几步搞定CocoaPods持续更新中。。。

作者: FMG | 来源:发表于2015-09-07 03:33 被阅读6649次

TOP:
Mac系统升级为macOS High sierra 10.13的时候,使用pod 时出现bad interpreter: No such file or directory
解决:
更新cocoapods
执行命令为:
$ sudo gem update --system
$ sudo gem install cocoapods -n/usr/local/bin

注:如果使用过程中出现:Insecure world writable dir /Users/xxx in PATH, mode 040777 when running Ruby commands
解决:chmod go-w /Users/xxx
xxx:为你mac 名称


一: 首次安装

  • 更新gem

      1、 sudo gem update --system
    
  • 更新ruby的软件源(仅限xcode 8一下,大于xcode8直接跳过第3.1、3.2)

      2、gem sources --remove https://rubygems.org/
      2.1 gem sources 为 https://gems.ruby-china.org/
    

以下命令二选一,这里是问题高发路段有问题,前往底部对照错误列表,以及找到解决方法
3.1、 gem sources -a http://ruby.taobao.org/
3.2、 gem sources -a https://ruby.taobao.org/
4、 gem sources -l

  • 安装CocoaPods
    5、 sudo gem install cocoapods

  • 替换CocoaPods的镜像索引

      6、pod repo remove master
      7、 pod repo add master https://gitcafe.com/akuandev/Specs.git
      8、pod repo update
    
  • 设置pod 仓库

    pod setup
    
  • 测试

    * pod --version  在这里能检测到版本就代表已经搞定
    
  • 卸载CocoaPods

     sudo gem uninstall cocoapods
    

二:安装错误:
由于升级到10.11以后安装cocodpods难免会碰到各种问题,下面有列举出不同的解决办法:

流程是这样的:正常安装-->碰到问题-->查看问题是否跟我列举出来一样-->解决办法1-->卸载-->正常安装-->解决办法2-->卸载-->正常安装。。。以此类推

1、分别执行下面命令卸载cocoapods和xcodeproj,如果你的机器上面有多个版本,选择All versions卸载 

    $ sudo gem uninstall cocoapods 
        $ sudo gem uninstall xcodeproj
2、 分别执行下面命令安装xcodeproj和cocoapods 

    $ sudo gem install xcodeproj 
        $ sudo gem install cocoapods

错误1、
如果是之前由于升级了系统导致,cocoaPods 不能用并报错误:expanded gem_path : usr/bin 这里报路径找不到错误,


解决办法: 
方法1:终端下:sudo gem install -n /usr/local/bin cocoapods 
方法2:
1、按住common + R ,然后持续按开机键
2、进入到电脑恢复模式,找到终端输入:csrutil disable 然后回车
3、重新启动
4、到正常模式的终端重新安装,(安全起见可以先卸载了再安装)

方法3:
sudo nvram boot-args="rootless=0"
sudo reboot

重启之后, 执行这个命令检查

sudo gem install cocoapods -V

办法4:
 sudo gem install -n /usr/local/bin cocoapods

错误2、
如果执行## 3.1 ##指令出现错误:

Error fetching http://ruby.taobao.org/:bad response Not Found 404(http://ruby.taobao.org/specs.4.8.gz)
解决:把下面即将操作的命令中的http改为https 就ok了

如果执行## 3.2 ##指令出现错误:

ERROR: SSL verification error at depth 1: unable to get local issuer certificate (20)

ERROR: You must add /C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Certification Authority to your local trusted store

ERROR: SSL verification error at depth 2: self signed certificate in certificate chain (19)

ERROR: Root certificate is not trusted (/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA)

解决办法:http://www.qingpingshan.com/pc/fwq/165342.html
如果还没解决,采用3.1指令

错误3、如果你的Mac是10.11以上的版本在 这里报路径找不到错误,

MGdeMacBook-Pro:~ mgf$ sudo gem install cocoapods
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/pod
$ pod setup 第一次报错
Setting up CocoaPods master repo
[!] /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

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

$ pod setup 第二次报错
Setting up CocoaPods master repo
[!] /usr/bin/git clone https://github.com/CocoaPods/Specs.git master

Cloning into 'master'...
fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Server aborted the SSL handshake

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer 
Password:
$ pod setup 第三次就不报错了,坐等一段时间提示成功就OK了

 CocoaPods安装东西的时候它要找到Xcode的Developer文件夹, 如果找不到会报如下错误
[!] /usr/bin/git clone http://git.oschina.net/akuandev/Specs.git master


xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun


最后的解决方法: 
sudo xcode-select -switch /Applications/Xcode-beta.app/Contents/Developer

/Applications/Xcode-beta.app/Contents/Developer这个路径 你可以打开Xcode显示包内容,找到那个文件夹拖到终端里面比较不容易错。 

错误4、如果是xcode 8 以上版本报错:

1、gem sources -l 
查看当前源是否在之前被自己替换为了淘宝资源,如果是
2、gem sources -r http://ruby.taobao.org/  
移除淘宝源,添加原本源
3、$gem source -a https://rubygems.org/ to read 

4、使用$gem sources -l 查看以下确保只有一个https://rubygems.org/源存在 
*** CURRENT SOURCES *** 
https://rubygems.org 
5、sudo gem install cocoa pods
。。。。

错误5、sudo gem install cocoa pods 报错:

ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted - /usr/bin/fuzzy_match
解决:sudo gem install -n /usr/local/bin cocoapods

注释事项:

  • 1.利用CocoPods管理类库后, 以后打开项目就用xxxx.xcworkspace 打开,而不是
    之前的.xcodeproj文件

  • 2.每次更改了Podfile文件,你需要重新执行一次pod update命令。

  • 3.CocoaPods在执行pod
    install和pod update时,会默认先更新一次CocoPods的spec仓库索引。使用--no-repo-update参数可以禁止其做索引更新操作

pod install
--no-repo-update

pod update
--no-repo-update  不重复更新整个仓库

在你以为所有的问题都解决的时候,点击install pod 的时候,额,又报错了

The dependency `XXX` is not used in any concrete target
The dependency `AFNetworking ` is not used in any concrete target

解决办法

其他平台版本什么的不变
target 'FMGApp' do
  pod 'JazzHands', '2.0.0'
pod 'SSKeychain', '1.2.3'
pod 'UMengSocial', '4.2.3'
end

注:FMGApp 为你的工程名字

good luck for you !

到这里基本大功告成了,一般使用的话用Xcode插件比较方便,当然你也可以用终端敲,下面给出CocoaPod在Xcode上的插件地址:https://github.com/CocoaPods/CocoaPods,下载下来直接运行,编译成功后关掉Xcode重新运行,会有提示框,点击Load就OK了

相关文章

网友评论

  • Never_Yg:有人遇到安装的时候这个报错吗
    Cloning into 'master'...
    fatal: unable to access 'https://github.com/CocoaPods/Specs.git/': Failed to connect to 127.0.0.1 port 8080: Connection refused
    _leem:@Fantasy_Yg cd到~/.cocoapods/repos/目录下,然后执行git clone git://github.com/CocoaPods/Specs.git master
  • 幸福的鱼:很详细,完美解决问题
  • 337b94dc718f:输入:pod repo add master https://gitcafe.com/akuandev/Specs.git
    提示:[!] To setup the master specs repo, please run `pod setup`.
    请问你遇到这个情况了吗?
    帆动世界: pod repo add master https://git.coding.net/hging/Specs.git
    也遇到了:[!] To setup the master specs repo, please run `pod setup`.
    light_of_king:@FMG 没见到解决办法
    FMG:@Echo_D 最近安装碰到了,文章已更新,请查看

本文标题:轻松几步搞定CocoaPods持续更新中。。。

本文链接:https://www.haomeiwen.com/subject/welycttx.html