一、升级cocoapods,加上 '-n /usr/local/bin' Cocoapods1.8版本以后使用CDN服务的方法
sudo gem install cocoapods -v 1.8.4
提示没有权限:You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory
# sudo gem update --system
# gem sources --remove https://rubygems.org/
# gem sources --add https://gems.ruby-china.com/
# sudo gem install -n /usr/local/bin cocoapods
# sudo gem install -n /usr/local/bin cocoapods --pre
二、解决macOS Catalina 安装cocoapods报错,macOS 10.15,使用brew安装cocoapods
1、以下2种方式都先会去下载Homebrew(本地路径:/usr/local/Homebrew,建议手动下载再复制进来)
方式一:
# brew cleanup -d -v
# brew install cocoapods
方式二:
# ruby -e "$(curl -fsSL [https://raw.githubusercontent.com/Homebrew/install/master/install](https://raw.githubusercontent.com/Homebrew/install/master/install))" < /dev/null 2> /dev/null
# brew install cocoapods
2、cocoapods1.10.0安装成功以后,需要链接,链接成功即是最新版cocoapods
Warning: cocoapods 1.10.0 is already installed, it's just not linked
# brew link cocoapods
# brew link --overwrite cocoapods
--------------------安装过程一些提示-------------------
# Target /usr/local/bin/pod
# already exists. You may want to remove it:
# rm '/usr/local/bin/pod'
# To force the link and overwrite all conflicting files:
# brew link --overwrite cocoapods
# To list all files that would be deleted:
# brew link --overwrite --dry-run cocoapods
---------------------------------------
macOS Catalina 安装cocoapods报错如下:
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
--with-ffi_c-dir
--without-ffi_c-dir
--with-ffi_c-include
--without-ffi_c-include=${ffi_c-dir}/include
--with-ffi_c-lib
--without-ffi_c-lib=${ffi_c-dir}/lib
--enable-system-libffi
--disable-system-libffi
--with-libffi-config
--without-libffi-config
--with-pkg-config
--without-pkg-config
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in `block in try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in `try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in `try_link'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:672:in `try_ldflags'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1832:in `pkg_config'
from extconf.rb:9:in `system_libffi_usable?'
from extconf.rb:42:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.13.1/mkmf.log
extconf failed, exit code 1
三、pod版本1.10.1新版的 CocoaPods 不允许用pod repo add直接添加master库了,可用清华镜像 repo更新(2022.05.26)
解决办法:
- 对于旧版的 CocoaPods 可以使用如下方法使用 tuna 的镜像:
pod repo remove master // 移除master源
pod repo add master https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git // 添加清华源
pod repo update // 更新资源库
- 新版的 CocoaPods 不允许用pod repo add直接添加master库了,但是依然可以:
cd ~/.cocoapods/repos // 进入pods资源库
pod repo remove master // 移除master源
git clone https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git master // 克隆清华源
最后进入自己的工程,在自己工程的podFile第一行加上(也可以不加 执行pod update操作后 会自动加上):
source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
网友评论