解决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.

相关文章
|
Swift iOS开发 Ruby
iOS CocoaPods 使用以及常见问题(上)
iOS CocoaPods 使用以及常见问题
801 0
|
iOS开发 开发者
📝 App备案与iOS云管理式证书 ,公钥及证书SHA-1指纹的获取方法
在iOS应用程序开发过程中,进行App备案并获取公钥及证书SHA-1指纹是至关重要的步骤。本文将介绍如何通过appuploader工具获取iOS云管理式证书 Distribution Managed 公钥及证书SHA-1指纹,帮助开发者更好地理解和应用该过程。
|
Swift iOS开发 Perl
如何解决Swift混编的module编译错误
前言很多iOS工程都是基于Object-C开发,再逐步向Swift演进,演进过程中不可避免要进行Swift混编。Swift模块需要支持LLVM Module规范,混编工程会遇到各种Module编译错误。这对于不熟悉的同学来说简直是灾难,严重影响开发效率。本文会介绍常见的Module编译错误,希望对大家有所帮助。常见错误1:Could not build module xxx当一个OC模块引用了Sw
7936 1
如何解决Swift混编的module编译错误
|
Linux 数据安全/隐私保护 iOS开发
如何使用 Xcode 打包导出 IPA 文件并进行 iOS 应用内测,无需支付苹果开发者账号费用?
如何使用 Xcode 打包导出 IPA 文件并进行 iOS 应用内测,无需支付苹果开发者账号费用?
|
CDN
Cocoapods报错 [!] CDN: trunk URL couldn't be downloaded: 解决方法
Cocoapods报错 [!] CDN: trunk URL couldn't be downloaded: 解决方法
2052 0
|
9月前
|
Dart 开发工具 Android开发
在macOS系统上配置Flutter环境的步骤
在macOS系统上配置Flutter环境的步骤
1128 62
|
Oracle Java 关系型数据库
Mac电脑上安装和配置Flutter开发环境
Mac电脑上安装和配置Flutter开发环境
856 158
|
Unix iOS开发 Ruby
解决CocoaPods installed but it is not working
解决CocoaPods installed but it is not working
824 5
|
iOS开发
IOS编译出现Command PhaseScriptExecution failed with a nonzero exit code
IOS编译出现Command PhaseScriptExecution failed with a nonzero exit code
2934 2
|
Web App开发 开发工具 Android开发
【Flutter】Flutter安装和配置(mac)
【Flutter】Flutter安装和配置(mac)

热门文章

最新文章