flutter run
Launching lib/main.dart on iPhone 12 Pro Max in debug mode...
Running Xcode build...
Xcode build done. 18.8s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
andler:
In module 'UIKit' imported from
/Users/Singer/work/iOSProject/Access/ios/Pods/Target Support
Files/launch_review/launch_review-prefix.pch:2:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platfor
m/Developer/SDKs/iPhoneSimulator14.5.sdk/System/Library/Frameworks/UIKit.fra
mework/Headers/UIApplication.h:123:1: note: 'openURL:' has been explicitly
marked deprecated here
- (BOOL)openURL:(NSURL*)url
API_DEPRECATED_WITH_REPLACEMENT("openURL:options:completionHandler:",
ios(2.0, 10.0)) NS_EXTENSION_UNAVAILABLE_IOS("");
^
........
Xcode's output:
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Constructing build description
note: Build preparation complete
Could not build the application for the simulator.
Error launching application on iPhone 12 Pro Max.
模拟器调试始终报错,真机调试就正常。
这让我感觉可能是指令集的问题
看了下输出的日志并没有明显的错误,都是一些警告,无关痛痒
看了下build目录已经生成了Runner.app
用命令查看了一下下面几个文件的指令集
lipo -info ios/Flutter/App.framework/App //x86_64 arm64
lipo -info ios/Flutter/Flutter.framework/Flutter ///x86_64 armv7 arm64
lipo -info build/ios/iphonesimulator/Runner.app/Runner //arm64
Runner是arm64指令集的,我的MacBookPro是Intel的也就x86_64的指令集 模拟器也就是x86_64,arm64的Runner.app无法安装到x86_64上面去
这让我想起了前几天配置的一个环境变量
查看环境变量
export -p
在里面发现一行
export FLUTTER_BUILD_MODE=release
通过下面的命令把FLUTTER_BUILD_MODE删除
unset FLUTTER_BUILD_MODE
重新执行
flutter run
OK 搞定 成功在iOS模拟器运行起来