草庐IT

Cocoapods安装

响彻天堂 2023-03-28 原文

前言:

cocopods安装安装之前,一定要安装好Xcode,否则在安装cocopods时会报错。

cocopods安装步骤

1,安装HomeBrew,看我其他文章Homebrew介绍和使用
2,安装ruby,Mac一般自带,更新就行。

brew install ruby // 安装ruby

3,升级ruby

sudo gem update --system  

4,查看ruby源

gem sources -l

//之后打印

*** CURRENT SOURCES ***
https://rubygems.org/

替换ruby源

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

查看是否替换成功

gem sources -l

如果出现的是https://gems.ruby-china.com/证明替换成功

5,安装最新版本:两个命令,建议用第2个。

//1,sudo gem命令安装(ruby安装)。
sudo gem install -n /usr/local/bin cocoapods

//2,Homebrew命令安装。
brew install cocoapods
//安装指定版本
brew install cocoapods  -v 1.0.1

Homebrew 踩坑Error: No similarly named formulae found.

==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "htop".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

解决办法:
重新安装一次homebrew-core

cd /usr/local/Homebrew/Library/Taps/homebrew/
rm -rf homebrew-core
git clone https://github.com/Homebrew/homebrew-core.git

如果运行pod install 报错:


/Library/Ruby/Site/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'minitest' (>= 5.1) among 39 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/jh/.local/share/gem/ruby/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0:/usr/local/Cellar/cocoapods/1.11.3/libexec' , execute `gem env` for more information
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1409:in `block in activate_dependencies'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1397:in `each'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1397:in `activate_dependencies'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1379:in `activate'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1415:in `block in activate_dependencies'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1397:in `each'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1397:in `activate_dependencies'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1379:in `activate'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1415:in `block in activate_dependencies'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1397:in `each'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1397:in `activate_dependencies'
    from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1379:in `activate'
    from /Library/Ruby/Site/2.6.0/rubygems.rb:286:in `block in activate_bin_path'
    from /Library/Ruby/Site/2.6.0/rubygems.rb:285:in `synchronize'
    from /Library/Ruby/Site/2.6.0/rubygems.rb:285:in `activate_bin_path'
    from /usr/local/Cellar/cocoapods/1.11.3/libexec/bin/pod:23:in `<main>'

网上说的升级ruby,重装home brew,卸载重新下载cocoapods,升级cocoapods。。。都都试了,不行。

最后,这么解决了的:
上面的信息:有这个/usr/local/Cellar/cocoapods。安装的cocoapods在这个目录/usr/local/Cellar下,出问题了。需要改成/usr/local/bin/pod
①,执行

gem list

打印

*** LOCAL GEMS ***

abbrev (default: 0.1.0)
actioncable (7.0.3)
actionmailbox (7.0.3)
actionmailer (7.0.3)
actionpack (7.0.3)
actiontext (7.0.3)
actionview (7.0.3)
activejob (7.0.3)
activemodel (7.0.3)
activerecord (7.0.3)
activestorage (7.0.3)
activesupport (7.0.3, 6.1.6)
addressable (2.8.0)
algoliasearch (1.27.5)
atomos (0.1.3)
base64 (default: 0.1.1)
benchmark (default: 0.2.0)
bigdecimal (default: 3.1.1)
builder (3.2.4)
bundler (default: 2.3.11)
CFPropertyList (3.0.5)
cgi (default: 0.3.1)
claide (1.1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.3)
colored2 (3.1.2)
concurrent-ruby (1.1.10)
crass (1.0.6)
csv (default: 3.2.2)
date (default: 3.2.2)
debug (1.4.0)
delegate (default: 0.2.0)
did_you_mean (default: 1.6.1)
digest (default: 3.1.0)
drb (default: 2.1.0)
english (default: 0.7.1)
erb (default: 2.2.3)
error_highlight (default: 0.3.0)
erubi (1.10.0)
escape (0.0.4)
etc (default: 1.3.0)
ethon (0.15.0)
fcntl (default: 1.0.1)
ffi (1.15.5)
fiddle (default: 1.1.0)
fileutils (default: 1.6.0)
find (default: 0.1.1)
forwardable (default: 1.3.2)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
getoptlong (default: 0.1.1)
gh_inspector (1.1.3)
globalid (1.0.0)
httpclient (2.8.3)
i18n (1.10.0)
io-console (default: 0.5.11)
io-nonblock (default: 0.1.0)
io-wait (default: 0.2.1)
ipaddr (default: 1.2.4)
irb (default: 1.4.1)
json (default: 2.6.1)
logger (default: 1.5.0)
loofah (2.18.0)
mail (2.7.1)
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.15.0)
molinillo (0.8.0)
mutex_m (default: 0.1.1)
nanaimo (0.3.0)
nap (1.1.0)
net-ftp (0.1.3)
net-http (default: 0.2.0)
net-imap (0.2.3)
net-pop (0.1.1)
net-protocol (default: 0.1.2)
net-smtp (0.3.1)
netrc (0.11.0)
nio4r (2.5.8)
nkf (default: 0.1.1)
nokogiri (1.13.6 x86_64-darwin)
observer (default: 0.1.1)
open-uri (default: 0.2.0)
open3 (default: 0.1.1)
openssl (default: 3.0.0)
optparse (default: 0.2.0)
ostruct (default: 0.5.2)
pathname (default: 0.2.0)
power_assert (2.0.1)
pp (default: 0.3.0)
prettyprint (default: 0.1.1)
prime (0.1.2)
pstore (default: 0.1.1)
psych (default: 4.0.3)
public_suffix (4.0.7)
racc (default: 1.6.0)
rack (2.2.3.1)
rack-test (1.1.0)
rails (7.0.3)
rails-dom-testing (2.0.3)
rails-html-sanitizer (1.4.2)
railties (7.0.3)
rake (13.0.6)
rbs (2.1.0)
rdoc (default: 6.4.0)
readline (default: 0.0.3)
readline-ext (default: 0.1.4)
reline (default: 0.3.0)
resolv (default: 0.2.1)
resolv-replace (default: 0.1.0)
rexml (3.2.5)
rinda (default: 0.1.1)
rss (0.2.9)
ruby-macho (2.5.1)
ruby2_keywords (default: 0.0.5)
securerandom (default: 0.1.1)
set (default: 1.0.2)
shellwords (default: 0.1.0)
singleton (default: 0.1.1)
stringio (default: 3.0.1)
strscan (default: 3.0.1)
syslog (default: 0.1.0)
tempfile (default: 0.1.2)
test-unit (3.5.3)
thor (1.2.1)
time (default: 0.2.0)
timeout (default: 0.2.0)
tmpdir (default: 0.1.2)
tsort (default: 0.1.0)
typeprof (0.21.2)
typhoeus (1.4.0)
tzinfo (2.0.4)
un (default: 0.2.0)
uri (default: 0.11.0)
weakref (default: 0.1.1)
websocket-driver (0.7.5)
websocket-extensions (0.1.5)
xcodeproj (1.21.0)
yaml (default: 0.2.0)
zeitwerk (2.5.4)
zlib (default: 2.1.1)

②,一个个删除关于cocoapods的库

gem uninstall cocoapods

gem uninstall cocoapods-core

gem uninstall cocoapods-downloader

gem uninstall cocoapods-plugins

gem uninstall cocoapods-search

gem uninstall cocoapods-stats

gem uninstall cocoapods-trunk

gem uninstall cocoapods-try

...上面的打印cocoapods都一一删除,仔细看看。

③,重新安装pod
在命令中,指定安装到/usr/bin/pods下,即可正常安装成功:

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

这里就成了,可以找个项目试下pod init 就行了。

注释:sudogem都是shell命令
sudo: 允许系统管理员让普通用户执行一些或者全部的root命令的一个工具。
(比如你不是/root账号,但是需要安装gcc软件,可以 sudo apt-get install gcc
gem: ruby包管理器gem

报错情况

错误1: M1电脑 pod install 错误

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: https://www.ruby-lang.org/bugreport.html

[IMPORTANT]
Don't forget to include the Crash Report log file under
DiagnosticReports directory in bug reports.

[1] 4669 abort pod install

解决方法: 使用brew install cocoapods 安装cocoapods, 再使用pod install即可

错误2: cocoapods报错fatal: unable to access ‘XXX.git/‘: LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection

首先,Ruby镜像一定要用(https://gems.ruby-china.org/),不要用淘宝的镜像(http://ruby.taobao.org/),淘宝的已经不好用了。

1:查看当前镜像库:

gem sources -l

2: 修改gem的库地址:

gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/

完成后确认下是否修改成功用gem sources -l查一下

pod install报错

出现1:

[!] Smart quotes were detected and ignored in your Podfile. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.

解决:
pod install几次

出现2:

Automatically assigning platform `ios` with version `10.0` on target `CloudLive` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

解决:
去掉 #

# platform :ios, '10.0'

改为

platform :ios, '10.0'

标准的如下:

# Uncomment the next line to define a global platform for your project
platform :ios, '10.0'

target '嘻嘻嘻' do
  
  pod 'AFNetworking', '~> 3.1.0'
  pod 'SDWebImage', '~>3.7.3'
  pod 'Masonry', '~> 1.0.2'
  pod 'HGTimerButton', '~> 1.0.3'
  pod 'YYModel'
  pod 'MJRefresh'
  pod 'MBProgressHUD'
  pod 'IQKeyboardManager', '~> 6.1.1'
  pod 'MJExtension'
  
  #pod 'Realm', '~> 3.1.0’
  
  # 分段控件
  #pod 'SGPagingView'
  
  #pod install --verbose --no-repo-update
  
end

有关Cocoapods安装的更多相关文章

  1. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

  2. ruby - 完全离线安装RVM - 2

    我打算为ruby​​脚本创建一个安装程序,但我希望能够确保机器安装了RVM。有没有一种方法可以完全离线安装RVM并且不引人注目(通过不引人注目,就像创建一个可以做所有事情的脚本而不是要求用户向他们的bash_profile或bashrc添加一些东西)我不是要脚本本身,只是一个关于如何走这条路的快速指针(如果可能的话)。我们还研究了这个很有帮助的问题:RVM-isthereawayforsimpleofflineinstall?但有点误导,因为答案只向我们展示了如何离线在RVM中安装ruby。我们需要能够离线安装RVM本身,并查看脚本https://raw.github.com/wayn

  3. ruby-on-rails - rails 目前在重启后没有安装 - 2

    我有一个奇怪的问题:我在rvm上安装了ruby​​onrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(

  4. ruby - 如何为 emacs 安装 ruby​​-mode - 2

    我刚刚为fedora安装了emacs。我想用emacs编写ruby。为ruby​​提供代码提示、代码完成类型功能所需的工具、扩展是什么? 最佳答案 ruby-mode已经包含在Emacs23之后的版本中。不过,它也可以通过ELPA获得。您可能感兴趣的其他一些事情是集成RVM、feature-mode(Cucumber)、rspec-mode、ruby-electric、inf-ruby、rinari(用于Rails)等。这是我当前用于Ruby开发的Emacs配置:https://github.com/citizen428/emacs

  5. ruby-on-rails - 无法在centos上安装therubyracer(V8和GCC出错) - 2

    我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e

  6. ruby - 通过 RVM (OSX Mountain Lion) 安装 Ruby 2.0.0-p247 时遇到问题 - 2

    我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search

  7. ruby - 如何在 Lion 上安装 Xcode 4.6,需要用 RVM 升级 ruby - 2

    我实际上是在尝试使用RVM在我的OSX10.7.5上更新ruby,并在输入以下命令后:rvminstallruby我得到了以下回复:Searchingforbinaryrubies,thismighttakesometime.Checkingrequirementsforosx.Installingrequirementsforosx.Updatingsystem.......Errorrunning'requirements_osx_brew_update_systemruby-2.0.0-p247',pleaseread/Users/username/.rvm/log/138121

  8. ruby - Fast-stemmer 安装问题 - 2

    由于fast-stemmer的问题,我很难安装我想要的任何ruby​​gem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=

  9. ruby - 安装 Ruby 时遇到问题(无法下载资源 "readline--patch") - 2

    当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub

  10. ruby - 通过 RVM 安装 Ruby 1.9.2 永远行不通! - 2

    当我执行>rvminstall1.9.2时一切顺利。然后我做>rvmuse1.9.2也很顺利。但是当涉及到ruby​​-v时..sam@sjones:~$rvminstall1.9.2/home/sam/.rvm/rubies/ruby-1.9.2-p136,thismaytakeawhiledependingonyourcpu(s)...ruby-1.9.2-p136-#fetchingruby-1.9.2-p136-#downloadingruby-1.9.2-p136,thismaytakeawhiledependingonyourconnection...%Total%Rece

随机推荐