[Flutter] 09-Flutter真机调试错误处理

AndroidStudio 运行Flutter项目是通过 Xcode 构建项目的,所以真机遇到问题,可以先使用Xcode打开对应iOS项目进行调试给出的错误信息也比较准确,编译没问题后用AndroidStudio真机运行项目。

下面总结了几个笔者在Flutter真机调试时错误处理:
问题1:运行FlutterSDK低版本项目的建议
问题2:Xcode iOS Flutter真机调试错误 It appears that your application still contains the default signing identifier
问题3:Xcode iOS Flutter真机调试错误: Could not build the precompiled application for the device
问题4:Xcode iOS Flutter真机调试错误:Could not install build/ios/iphoneos/Runner.app on

问题1:运行FlutterSDK低版本项目的建议

由于FlutterSDK更新比较频繁,有时下载一个项目后会发现,报各种bug,各种问题,下面总结下处理步骤:
1> 找到pubspec.yaml 文件,执行 flutter get pub 安装项目所需插件。
2> 确定低版本项目的环境配置是否和当前电脑环境一致,下面给出一个笔者下载的低版本项目所需运行环境:

Flutter SDK (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.13.6 17G2112, locale zh-Hans-CN, Dart SDK : 2.5.0)

如果报一些的第三方库方法或者参数错误,查看电脑配置环境Flutter SDK是否高于v1.5.4。笔者当时配置Flutter SDK版本为1.7.2,找到Flutter SDK所在文件夹,git reset --hard commit_id 回退到指定版本v1.5.4后解决。
Flutter官网获取commitId
Flutter github项目下获取commitId

问题2:Xcode iOS Flutter真机调试错误 It appears that your application still contains the default signing identifier

错误信息:

Could not build the precompiled application for the device.
It appears that your application still contains the default signing identifier.
Try replacing ‘com.example‘ with your signing id in Xcode:
open ios/Runner.xcworkspace
Error launching application on iPhone.

原因:真机调试时候,应用bundle Id和苹果证书上注册的不一致,或者没有安装苹果开发者证书。

解决:打开xcode修改bundle Id。选择有效期内的苹果开发者证书。注意xcode版本和编译系统版本要和iphone手机系统搭配。

问题3:Xcode iOS Flutter真机调试错误: Could not build the precompiled application for the device

错误信息:

Could not build the precompiled application for the device.
Error launching application on iPhone8p.

解决:

  • 首先Xcode打开对应iOS项目,确定singing配置和bundle Id有效,如下图:


    [Flutter] 09-Flutter真机调试错误处理_第1张图片
    singing配置
  • 然后打开Xcode,File->Workspace Settings-> 找到Build System 选项修改为: Legacy Build System。

  • 编译没问题后Xcode真机运行,如果有下面弹窗提示,需要真机需要信任运行app ,真机上操作步骤: 手机设置->通用->设备管理->找到运行app设置信任`。
[Flutter] 09-Flutter真机调试错误处理_第2张图片
  • 修改后重新真机运行AndroidStudio。

问题4:Xcode iOS Flutter真机调试错误:Could not install build/ios/iphoneos/Runner.app on

错误信息:

Could not install build/ios/iphoneos/Runner.app on xxxxxx.
Try launching Xcode and selecting "Product > Run" to fix the problem:
  open ios/Runner.xcworkspace
Error launching application on iPhonesk8p.

原因: 真机上没有信任运行的app!
解决: 手机设置->通用->设备管理->找到运行app设置信任

你可能感兴趣的:([Flutter] 09-Flutter真机调试错误处理)