Mac M1环境下Kotlin MultiPlatform的Cocoapods配置错误求助
解决Apple M1设备上Kotlin MultiPlatform的Cocoapods环境问题
在Android Studio中启动Kotlin MultiPlatform项目时,若遇到Cocoapods安装失败,可通过kdoctor检测环境定位问题。本次检测出两个核心异常,对应解决方案如下:
异常1:系统Ruby与Apple M1的Cocoapods不兼容
Apple M1设备自带的系统Ruby版本无法适配Cocoapods,需通过第三方工具安装独立Ruby并设置为默认版本。
解决方案(以Homebrew为例):
- 安装Ruby:
brew install ruby - 将Homebrew安装的Ruby路径添加到Shell配置文件(根据使用的Shell选择
~/.zshrc或~/.bash_profile):echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc - 刷新配置文件使修改生效:
source ~/.zshrc - 验证Ruby版本,确认已切换至Homebrew安装的版本:
ruby --version
异常2:Homebrew安装的Cocoapods未链接到系统路径
已通过Homebrew完成Cocoapods安装,但未将其链接到/usr/local/bin,导致系统无法识别Cocoapods命令。
解决方案:
执行以下命令完成强制链接:
brew link --overwrite cocoapods
环境检测原始输出
kdoctor ─╯ Environment diagnose (to see all details, use -v option): [✓] Operation System [✓] Java [✓] Android Studio [✓] Xcode [✖] Cocoapods ✖ System ruby is currently used CocoaPods is not compatible with system ruby installation on Apple M1 computers. Please install ruby via Homebrew, rvm, rbenv or other tool and make it default Detailed information: https://stackoverflow.com/questions/64901180/how-to-run-cocoapods-on-apple-silicon-m1/66556339#66556339 ✖ Cocoapods are installed via Homebrew but not linked to /usr/local/bin Execute 'brew link --overwrite cocoapods' Conclusion: ✖ KDoctor has diagnosed one or more problems while checking your environment. Please check the output for problem description and possible solutions.
内容的提问来源于stack exchange,提问作者Ashok Nayak
相关产品推荐
相关产品推荐

