Flutter项目iOS模拟器运行报错:Runner不兼容当前Mac
Flutter iOS模拟器运行崩溃问题解决
问题现象
在VSCode中运行Flutter项目到iOS模拟器时,程序持续崩溃,Xcode弹出提示:
Runner quit unexpectedly.
Click Reopen to open the application again.
Click Report to see more detailed information and send a report to Apple.
点击重新打开后,出现提示:You can’t open the application “Runner” because this application is not supported on this Mac
已安装Xcode,核心崩溃报告关键信息如下:
------------------------------------- Translated Report (Full Report Below) ------------------------------------- Incident Identifier: 219EEFA2-2F1C-40A2-A282-65B8CC5B42BD CrashReporter Key: 04969868-FD54-972B-ACE2-051A54D4CD91 Hardware Model: MacBookAir10,1 Process: Runner [38143] Path: path to core simulator here Identifier: <my bundle id> Version: 1.0.0 (1) Code Type: X86-64 (Native) Role: Foreground Parent Process: launchd_sim [1433] Coalition: com.apple.CoreSimulator.SimDevice.1591F679-92E8-4914-B779-E3E56F97120D [1155] Responsible Process: SimulatorTrampoline [1422] Date/Time: 2024-09-14 12:40:01.0866 -0400 Launch Time: 2024-09-14 12:39:53.2309 -0400 OS Version: macOS 14.6.1 (23G93) Release Type: User Report Version: 104 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Termination Reason: SIGNAL 6 Abort trap: 6 Terminating Process: Runner [38143] Triggered by Thread: 4 Last Exception Backtrace: 0 CoreFoundation 0x112875521 __exceptionPreprocess + 226 1 libobjc.A.dylib 0x10f0947e8 objc_exception_throw + 48 2 CoreFoundation 0x11287502f -[NSException init] + 0 3 Runner 0x104314c65 GADApplicationVerifyPublisherInitializedCorrectly + 214 4 Runner 0x104314e23 0x10426b000 + 695843 5 libdispatch.dylib 0x11266d3ec _dispatch_call_block_and_release + 12 6 libdispatch.dylib 0x11266e6d8 _dispatch_client_callout + 8 7 libdispatch.dylib 0x112671793 _dispatch_queue_override_invoke + 1587 8 libdispatch.dylib 0x112680e26 _dispatch_root_queue_drain + 372 9 libdispatch.dylib 0x112681888 _dispatch_worker_thread2 + 244 10 libsystem_pthread.dylib 0x11c4ceb43 _pthread_wqthread + 262 11 libsystem_pthread.dylib 0x11c4cdacf start_wqthread + 15
问题根源
从崩溃栈可以看到,崩溃触发于GADApplicationVerifyPublisherInitializedCorrectly方法,这是Google AdMob SDK的验证逻辑,说明核心问题出在AdMob相关配置或初始化上:
- 未正确配置AdMob发布者ID
- AdMob SDK未完成初始化就被调用
- 模拟器架构与编译产物不兼容(Code Type显示X86-64,若模拟器为ARM架构可能存在冲突)
解决步骤
1. 检查AdMob配置
- 打开
ios/Runner/Info.plist,确认已添加GADApplicationIdentifier字段,值为你的AdMob发布者ID:<key>GADApplicationIdentifier</key> <string>ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy</string> - 确保发布者ID格式正确,无拼写错误
2. 调整AdMob初始化时机
在Flutter代码中,确保在runApp之后再初始化AdMob,避免提前调用导致验证失败:
void main() { WidgetsFlutterBinding.ensureInitialized(); runApp(const MyApp()); // 延迟初始化AdMob,确保App启动完成后再执行 Future.delayed(const Duration(seconds: 1), () { MobileAds.instance.initialize(); }); }
3. 修复模拟器架构兼容
- 打开Xcode,选择Runner项目,进入
Build Settings - 找到
Architectures,设置为Standard Architectures (arm64, x86_64) - 找到
Excluded Architectures,在Debug模式下:- Intel Mac添加
arm64 - Apple Silicon Mac添加
x86_64
- Intel Mac添加
- 清理构建缓存并重新安装依赖:
flutter clean cd ios && pod deintegrate && pod install cd ..
4. 重置iOS模拟器
- 打开iOS模拟器,点击
Device->Erase All Content and Settings - 重启模拟器后重新运行项目
内容的提问来源于stack exchange,提问作者Julia Pak
相关产品推荐
相关产品推荐

