在一个升级了Mac Os版本到10.12.2,Xcode 版本升级到8.2.1 后的周末,在新建了一个新工程写Demo的时候发现自己的Cocoapods在Pod install时创建xcworkspace失败。
错误提示如下:
localhost:Lottery Fuhanyu$ pod init
localhost:Lottery Fuhanyu$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Installing MBProgressHUD (1.0.0)
Generating Pods project
Abort trap: 6
查询网上解决方案有卸载掉所有cocopods版本,并安装新版本。
删除所有版本
gem uninstall cocoapods
gem uninstall cocoapods-core
gem uninstall cocoapods-deintegrate
gem uninstall cocoapods-downloader
gem uninstall cocoapods-plugins
gem uninstall cocoapods-search
gem uninstall cocoapods-stats
gem uninstall cocoapods-try
gem uninstall cocoapods-trunk
安装新版本
gem install cocoapods --pre
在安装新版本的时候出现问题,提示在原淘宝的ruby环境下无法找到cocoapod内容
localhost:Lottery Fuhanyu$ sudo gem install cocopods
ERROR: Could not find a valid gem 'cocopods' (>= 0), here is why:
Unable to download data from http://ruby.taobao.org/ - bad response Not Found 404 (http://ruby.taobao.org/latest_specs.4.8.gz)
在访问RubyGems镜像 淘宝网后发现:
RubyGems 镜像的管理工作以后将交由 Ruby China 负责,本站将不在继续维护,本站的维护者已经或即将参与到 Ruby China 镜像 的维护工作中,目前已将安装请求重定向到 Ruby China 镜像,请大家注意更换本地的 Gem Source。
切换方法
$ gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
$ gem sources -l
*** CURRENT SOURCES ***
https://gems.ruby-china.org
# 请确保只有 gems.ruby-china.org
$ gem install rails
完成并安装好最新的Cocopods后,执行pod install依旧报错
localhost:Lottery Fuhanyu$ pod --version
1.1.1
localhost:Lottery Fuhanyu$ pod install
Analyzing dependencies
Downloading dependencies
Installing AFNetworking (3.1.0)
Installing MBProgressHUD (1.0.0)
Generating Pods project
Abort trap: 6
继续进行尝试,企图尝试升级Ruby版本,当前机器Ruby版本为2.0.0。
localhost:Ping2_iOSClient Fuhanyu$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
查询可更新的Ruby版本
localhost:Ping2_iOSClient Fuhanyu$ rvm list known
# MRI Rubies
[ruby-]1.8.6[-p420]
[ruby-]1.8.7[-head] # security released on head
[ruby-]1.9.1[-p431]
[ruby-]1.9.2[-p330]
[ruby-]1.9.3[-p551]
[ruby-]2.0.0[-p648]
[ruby-]2.1[.10]
[ruby-]2.2[.6]
[ruby-]2.3[.3]
[ruby-]2.4[.0-rc1]
ruby-head
以下省略...
执行最新Ruby版本安装报错
localhost:Ping2_iOSClient Fuhanyu$ rvm install 2.2.4
Searching for binary rubies, this might take some time.
Found remote file https://rubies.travis-ci.org/osx/10.12/x86_64/ruby-2.2.4.tar.bz2
Checking requirements for osx.
Installing requirements for osx.
Updating system.......
Error running 'requirements_osx_brew_update_system ruby-2.2.4',
showing last 15 lines of /Users/Fuhanyu/.rvm/log/1482803016_ruby-2.2.4/update_system.log
https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.'
++ rvm_pretty_print stderr
++ case "${rvm_pretty_print_flag:=auto}" in
++ case "${TERM:-dumb}" in
++ case "$1" in
++ [[ -t 2 ]]
++ return 1
++ printf %b 'Failed to update Homebrew, follow instructions here:
https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.\n'
Failed to update Homebrew, follow instructions here:
https://github.com/Homebrew/homebrew/wiki/Common-Issues
and make sure `brew update` works before continuing.
++ return 1
Requirements installation failed with status: 1.
发现在执行brew update时出错,手动执行brew update
localhost:local Fuhanyu$ brew update
Error: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil or running Cocktail cleanup/optimizations
are known to do this.
You should probably change the ownership and permissions of /usr/local
back to your user account.
sudo chown -R $(whoami):admin /usr/local
发现在Mac OS版本更新后Apple对于usr文件进行了权限设置,所以执行:
localhost:local Fuhanyu$ sudo chown -R $(whoami):admin /usr/local
localhost:local Fuhanyu$ brew update
warning: no common commits
^COne sec, just cleaning up
Already on 'master'
Error: Failure while executing: git pull --ff --no-rebase --quiet origin refs/heads/master:refs/remotes/origin/master
localhost:local Fuhanyu$ rvm --version
rvm 1.28.0 (latest) by Wayne E. Seguin , Michal Papis [https://rvm.io/]
发现错误
Failure while executing: git pull --ff --no-rebase --quiet origin refs/heads/master:refs/remotes/origin/master
依次执行
localhost:local Fuhanyu$ git remote add origin https://github.com/Homebrew/homebrew.git
localhost:local Fuhanyu$ git fetch origin
localhost:local Fuhanyu$ git reset --hard origin/master
再次尝试手动执行brew update成功
localhost:local Fuhanyu$ brew update
==> **Homebrew has enabled anonymous aggregate user behaviour analytics.**
**Read the analytics documentation (and how to opt-out) here:**
** ****https://git.io/brew-analytics**
==> **Tapping homebrew/core**
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 3801, done.
remote: Compressing objects: 100% (3683/3683), done.
remote: Total 3801 (delta 20), reused 319 (delta 6), pack-reused 0
Receiving objects: 100% (3801/3801), 3.03 MiB | 120.00 KiB/s, done.
Resolving deltas: 100% (20/20), done.
Tapped 3677 formulae (3,830 files, 9.5M)
Updated 1 tap (caskroom/cask).
==> **Deleted Formulae**
caskroom/cask/brew-cask
==> **Migrating HOMEBREW_REPOSITORY (please wait)...**
==> **Migrated HOMEBREW_REPOSITORY to /usr/local/Homebrew!**
Homebrew no longer needs to have ownership of /usr/local. If you wish you can
return /usr/local to its default ownership with:
sudo chown root:wheel /usr/local
成功后执行Ruby版本升级rvm install 2.3.3(别问我为什么选这个版本233333)
localhost:local Fuhanyu$ rvm install 2.3.3
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/x86_64/ruby-2.3.3.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating Homebrew...
Installing requirements for osx.
Updating system.....
Installing required custom packages: homebrew/dupes homebrew/dupes.
Installing required packages: zlib, autoconf, automake, libtool, pkg-config, coreutils, zlib, libyaml, readline, libksba, openssl.............
Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/Fuhanyu/.rvm/rubies/ruby-2.3.3, this may take a while depending on your cpu(s)...
ruby-2.3.3 - #downloading ruby-2.3.3, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
省略...
赶快执行以下pod install试试,再看看Ruby版本是否已更新过
localhost:local Fuhanyu$ cd /Users/Fuhanyu/Desktop/My\ code/DEMO/Lottery
localhost:Lottery Fuhanyu$ pod install
/Library/Ruby/Site/2.0.0/rubygems.rb:270:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.0.0/rubygems.rb:298:in `activate_bin_path'
from /usr/local/bin/pod:22:in `'
localhost:Lottery Fuhanyu$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
提示Cocoapods不存在,可能是不知道再哪次尝试的时候又给删了,再安装一下。
localhost:Lottery Fuhanyu$ gem install cocoapods --pre
重新创建一个新项目尝试Cocoapods的使用
localhost:Ping2_iOSClient Fuhanyu$ cd /Users/Fuhanyu/Desktop/My\ code/DEMO/CocoapodsTest
localhost:CocoapodsTest Fuhanyu$ pod init
localhost:CocoapodsTest Fuhanyu$ vim podfile
localhost:CocoapodsTest Fuhanyu$ pod install
Analyzing dependencies
Downloading dependencies
Installing Masonry (1.0.2)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `CocoapodsTest.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
Success!