解决CocoaPods安装卡住反应慢或失败

简介: 解决CocoaPods安装卡住反应慢或失败

使用Flutter打包IOS,都会有三方依赖。IOS的依赖是用CocoaPods来管理的。使用Flutter doctor会提示安装CocoaPods.

根据提示安装CocoaPods,直接安装就卡在这里一直不动了。

$sudo gem install cocoapods

在网上找到个参数,可以查看安装进度,在最后加上-V。

# 注意V是大写
$sudo gem install cocoapods -V 

看到安装过程,发现是网的问题,因为gem的源地址在国外

解决gem安装慢或卡住

  • 使用梯子直接安装。
  • 将gem的源改为国内镜像。

替换源是最简单的方法

# 替换源
$ gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
# 查看替换后的源地址
$ gem sources -l
https://gems.ruby-china.com
# 确保只有 gems.ruby-china.com

解决Failed to build gem native extension

替换gem源之后安装到最后又碰到以下问题。

Building native extensions.  This could take a while...
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.14.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20210203-987-tfjdrx.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
ERROR:  Error installing cocoapods:
  ERROR: Failed to build gem native extension.

    Building has failed. See above output for more information on the failure.
extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.14.2 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.14.2/gem_make.out

Google搜索发现是MacOS缺少一些头文件。因为我的是10.14。所以直接使用以下命令安装工具包。

$ open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

如果不想用命令也可以直接进入这个目录,双击安装,都会弹出安装界面。

安装后,重新使用sudo gem install cocoapods就能安装成功了。

最后运行Flutter doctor,IOS显示正常。

$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.14.6 18G7016 darwin-x64,
    locale zh-Hans-CN)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 4.0)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

相关文章
|
2月前
|
iOS开发 MacOS
CocoaPods安装失败解决方法
CocoaPods安装失败解决方法
50 2
|
5月前
|
iOS开发
Xcode 10.2.1 Error:Multiple commands produce问题及解决方案
Xcode 10.2.1 Error:Multiple commands produce问题及解决方案
436 0
|
SQL 安全 关系型数据库
需要binlog的场景下,“暴力”干掉历史binlog文件,尽情释放磁盘空间
需要binlog的场景下,“暴力”干掉历史binlog文件,尽情释放磁盘空间
103 0
|
IDE 开发工具
STM32bug【 KEILMDK中出现STLink强制更新提示,又无法更新】
STM32bug【 KEILMDK中出现STLink强制更新提示,又无法更新】
364 0
|
网络协议 Windows
【错误集】不定时更新
文章目录 前言 一、内容 二、服务(配置文件) 2.1 DNS服务无效(文件无权
154 0
【错误集】不定时更新
FAQ系列 | SLAVE为什么停滞一直不动了
FAQ系列 | SLAVE为什么停滞一直不动了
|
负载均衡 Dubbo 应用服务中间件
我叫你不要重试,你非得重试。这下玩坏了吧? (中)
我叫你不要重试,你非得重试。这下玩坏了吧? (中)
91 0
我叫你不要重试,你非得重试。这下玩坏了吧? (中)
|
XML Dubbo 应用服务中间件
我叫你不要重试,你非得重试。这下玩坏了吧? (上)
我叫你不要重试,你非得重试。这下玩坏了吧? (上)
117 0
我叫你不要重试,你非得重试。这下玩坏了吧? (上)
|
负载均衡 Dubbo 应用服务中间件
我叫你不要重试,你非得重试。这下玩坏了吧? (下)
我叫你不要重试,你非得重试。这下玩坏了吧? (下)
314 0
我叫你不要重试,你非得重试。这下玩坏了吧? (下)
Linux 执行 df -h 卡着不动,HANG 住了,怎么破?
最近,查看磁盘空间时,执行 df -h 时,命令 hang 住了,一直没有反应!
Linux 执行 df -h 卡着不动,HANG 住了,怎么破?