配置Flutter的ios环境卡了很久,简单记录一下踩的坑和最后的解决方案
首先需要安装Xcode(这一步基本没啥问题)
安装完Xcode之后再次执行 flutter doctor
提示安装CocoaPods,然后麻烦的问题就来了
安装gem 改ruby依赖源等都很简单,最后卡在sudo gem install cocoapods
这条命令上,直接执行提示目录权限不够,加上--system会报错gem版本太低,更新gem又会提示依赖库需要更高的ruby版本,以及各种依赖版本报错等...
当前系统默认的ruby版本v2.3.3 gem版本v1.6
尝试了一些stackoverflow上的解决方案但是没有成功,例如下边的:
sudo gem install -n /usr/local/bin cocoapods
最终解决的过程
1.安装Rvm(RVM是一个命令行工具,可以提供一个便捷的多版本 Ruby 环境的管理和切换)
$ curl -L https://get.rvm.io | bash -s stable
2.载入环境变量
$ source ~/.bashrc
$ source ~/.bash_profile
3.rvm安装ruby环境
$ rvm install 2.2.4
4.设置为默认版本
$ rvm use 2.2.4 --default
5.再次执行cocoapods安装报了openssl的错误于是用RVM升级Ruby
$ rvm install ruby
最终环境
ruby 2.6.3p62
gem 3.0.8
执行sudo gem install cocoapods
直接成功,无异常
flutter doctor -v
[✓] Flutter (Channel master, v1.15.19-pre.9, on Mac OS X 10.14.6 18G3020, locale
zh-Hans-CN)
• Flutter version 1.15.19-pre.9 at /Users/shenxiaoshun/flutter
• Framework revision e13e17009d (4 hours ago), 2020-03-06 21:38:35 -0800
• Engine revision 5aff311948
• Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/shenxiaoshun/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.9.0
[✓] Android Studio (version 3.6)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
[✓] Connected device (1 available)
• iPhone 11 Pro Max • 57ED11E3-56E6-486B-80D3-B7DDE1CE5F75 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• No issues found!
结束~
网友评论