M1配置Flutter环境及运行项目常见问题解决方法

环境:

2021 iMac M1

Flutter 3.0.5

Android Studio Arctic Fox

配置文件zshrc(M1之后默认类型由bash改成了zshrc)

常见问题及解决方法:

以下报错并非将所有错误都显示出来,只展示了前部分。

  • 没有flutter命令
    解决:确定flutterSDK已配置在zshrc中,使用 source ~/.zshrc来强制当前窗口使用zshrc配置。M1的机型默认不是bash而是zshrc

  • error: could not find included file ‘Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig’ in search paths (in target ‘Runner’)
    解决:xxx.xcconfig文件未生成,需pod install,网络不好情况下请使用恰当的网络pod

  • pod (mach-o file, but is an incompatible architecture (have (arm64), need (x86_6
    解决:sudo arch -x86_64 gem install ffi arch -x86_64 pod install M1以x86模式运行命令 ;或者arch -x86_64 $SHELL运行命令。M1机型是arm架构,而现在大部分mac还是x86架构。

  • CocoaPods could not find compatible versions for pod “xxx“
    解决:AS内搜该插件,检查该插件的最低iOS deployed target是否与Xcode项目最低版本持平。

  • xcode lib/main.dart: Error: Error when reading ‘lib/main.dart’: No such file or di
    解决:target/Flutter/Generated.xcconfig,检查其内的FLUTTER_APPLICATION_PATH=/Users/mac_m1/xxx 是否为flutter启动路径

  • 找不到iOS设备/ Xcode installation is incomplete; full installation is necessary for iOS development
    解决:sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
    sudo xcodebuild -runFirstLaunch (注意Xcode版本号及安装路径,多个Xcode容易存在路径写错问题)

  • 无法运行iOS真机:Exception: CocoaPods not installed or not in valid state.
    解决:open /Applications/Android\ Studio.app (注意AS版本号及安装路径)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值