You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter应用无法在iOS模拟器运行,求助解决编译及崩溃问题

Flutter iOS 模拟器构建与启动崩溃问题

问题描述

开发的Flutter应用在Android设备上运行正常,但在iOS模拟器上出现两类问题:

  1. 初始构建阶段因权限问题失败
  2. 从零重建项目后应用可安装,但启动即崩溃

初始构建错误日志

Launching lib/main.dart on iPhone 13 in debug mode...
Running Xcode build...                                                   
 └─Compiling, linking and signing...                         5,0s
Xcode build done.                                           28,8s
Failed to build iOS app
Error output from Xcode build:
↳
    2022-07-11 18:35:57.582 xcodebuild[15576:52607] Requested but did not find extension point with identifier
    Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in
    com.apple.dt.IDEWatchSupportCore
    2022-07-11 18:35:57.583 xcodebuild[15576:52607] Requested but did not find extension point with identifier
    Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in
    com.apple.dt.IDEWatchSupportCore
    ** BUILD FAILED **


Xcode's output:
↳
    Writing result bundle at path:
        /var/folders/hn/zclkrvcx6z727_k0rssl_1x00000gn/T/flutter_tools.xkj85b/flutter_ios_build_temp_direwEhYz/temporary_xcresult_bundle

    /Users/haldiz/Library/Developer/Xcode/DerivedData/Runner-bxvlefboatfugfbdpodmkzmhtotl/Build/Intermediates.noindex/Runner.build/Debug-iphonesimulator/Runne
    r.build/Script-014E83FBDAF3F33F05F23D32.sh: line 2: /Users/haldiz/Downloads/projectmain/ios/Pods/Target Support
    Files/Pods-Runner/Pods-Runner-frameworks.sh: Permission denied
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/haldiz/Downloads/projectmain/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to
    8.0, but the range of supported deployment target versions is 9.0 to 15.5.99. (in target 'leveldb-library' from project 'Pods')

    Result bundle written to path:
        /var/folders/hn/zclkrvcx6z727_k0rssl_1x00000gn/T/flutter_tools.xkj85b/flutter_ios_build_temp_direwEhYz/temporary_xcresult_bundle


Could not build the application for the simulator.
Error launching application on iPhone 13.

已尝试的无效解决方案

  • 更新macOS、Xcode及开发工具至最新版本
  • 删除并重新创建Podfile
  • 删除并重新创建iOS文件夹
  • 卸载并重新安装开发工具

编辑1:启动崩溃日志

从零重建项目后应用成功安装至模拟器,但启动时崩溃,日志如下:

Date/Time:           2022-07-13 15:27:24.5135 +0300
Launch Time:         2022-07-13 15:27:24.1819 +0300
OS Version:          macOS 12.4 (21F79)
Release Type:        User
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                      0x7fff20420ae6 __exceptionPreprocess + 226
1   libobjc.A.dylib                     0x7fff20177e78 objc_exception_throw + 48
2   UIKitCore                           0x7fff24816dc2 -[UIStoryboard name] + 0
3   UIKitCore                           0x7fff24695507 -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 75
4   UIKitCore                           0x7fff24695aa6 -[UIApplication _loadMainInterfaceFile] + 274
5   UIKitCore                           0x7fff24694577 -[UIApplication _runWithMainScene:transitionContext:completion:] + 971
6   UIKitCore                           0x7fff23cbd907 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
7   UIKitCore                           0x7fff2424bdb6 _UIScenePerformActionsWithLifecycleActionMask + 88
8   UIKitCore                           0x7fff23cbe416 __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198
9   UIKitCore                           0x7fff23cbde28 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 296
10  UIKitCore                           0x7fff23cbe247 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 819
11  UIKitCore                           0x7fff23cbdadb -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 345
12  UIKitCore                           0x7fff23cc5d73 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 178
13  UIKitCore                           0x7fff241556ab +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 871
14  UIKitCore                           0x7fff2426865e _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 240
15  UIKitCore                           0x7fff23cc5a79 -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 361
16  UIKitCore                           0x7fff23ae896f __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke + 797
17  UIKitCore                           0x7fff23ae7419 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253
18  UIKitCore                           0x7fff23ae85a8 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 208
19  UIKitCore                           0x7fff24692b20 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 508
20  UIKitCore                           0x7fff2417dab7 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 358
21  FrontBoardServices                  0x7fff25aa20ae -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 391
22  FrontBoardServices                  0x7fff25acab41 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176 + 102
23  FrontBoardServices                  0x7fff25aafad5 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209
24  FrontBoardServices                  0x7fff25aca80f __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 352
25  libdispatch.dylib                   0x7fff20106508 _dispatch_client_callout + 8
26  libdispatch.dylib                   0x7fff20109052 _dispatch_block_invoke_direct + 281
27  FrontBoardServices                  0x7fff25af07a5 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
28  FrontBoardServices                  0x7fff25af048b -[FBSSerialQueue _targetQueue_performNextIfPossible] + 433
29  FrontBoardServices                  0x7fff25af0950 -[FBSSerialQueue _performNextFromRunLoopSource] + 22
30  CoreFoundation                      0x7fff2038f38a __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
31  CoreFoundation                      0x7fff2038f282 __CFRunLoopDoSource0 + 180
32  CoreFoundation                      0x7fff2038e764 __CFRunLoopDoSources0 + 248
33  CoreFoundation                      0x7fff20388f2f __CFRunLoopRun + 878
34  CoreFoundation                      0x7fff203886d6 CFRunLoopRunSpecific + 567
35  GraphicsServices                    0x7fff2bededb3 GSEventRunModal + 139
36  UIKitCore                           0x7fff24690e0b -[UIApplication _run] + 912
37  UIKitCore                           0x7fff24695cbc UIApplicationMain + 101
38  Runner                                 0x105fd8dff main + 63 (AppDelegate.swift:6)
39  dyld                                   0x10dd5751e start + 462

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib              0x7fff60c5900e __pthread_kill + 10
1   libsystem_pthread.dylib             0x7fff60c9a1ff pthread_kill + 263
2   libsystem_c.dylib                   0x7fff200fab94 abort + 120
3   libc++abi.dylib                     0x7fff20252818 abort_message + 231
4   libc++abi.dylib                     0x7fff20243e7d demangling_terminate_handler() + 266
5   libobjc.A.dylib                     0x7fff201780d1 _objc_terminate() + 96
6   libc++abi.dylib                     0x7fff20251c47 std::__terminate(void (*)()) + 8
7   libc++abi.dylib                     0x7fff20251be9 std::terminate() + 41
8   libdispatch.dylib                   0x7fff2010651c _dispatch_client_callout + 28
9   libdispatch.dylib                   0x7fff20109052 _dispatch_block_invoke_direct + 281
10  FrontBoardServices                  0x7fff25af07a5 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
11  FrontBoardServices                  0x7fff25af048b -[FBSSerialQueue _targetQueue_performNextIfPossible] + 433
12  FrontBoardServices                  0x7fff25af0950 -[FBSSerialQueue _performNextFromRunLoopSource] + 22
13  CoreFoundation                      0x7fff2038f38a __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14  CoreFoundation                      0x7fff2038f282 __CFRunLoopDoSource0 + 180
15  CoreFoundation                      0x7fff2038e764 __CFRunLoopDoSources0 + 248
16  CoreFoundation                      0x7fff20388f2f __CFRunLoopRun + 878
17  CoreFoundation                      0x7fff203886d6 CFRunLoopRunSpecific + 567
18  GraphicsServices                    0x7fff2bededb3 GSEventRunModal + 139
19  UIKitCore                           0x7fff24690e0b -[UIApplication _run] + 912
20  UIKitCore                           0x7fff24695cbc UIApplicationMain + 101
21  Runner                                 0x105fd8dff main + 63 (AppDelegate.swift:6)
22  dyld                                   0x10dd5751e start + 462

解决方案建议

针对初始构建权限问题

  1. 修复Pod脚本执行权限
    终端进入项目的ios目录,执行以下命令为Pod脚本添加执行权限:

    chmod +x Pods/Target\ Support\ Files/Pods-Runner/Pods-Runner-frameworks.sh
    

    完成后重新执行flutter run。

  2. 统一Pod部署目标版本
    针对leveldb-library部署目标过低的警告,在Podfile末尾添加以下代码,强制所有Pods使用统一的最低部署版本:

    post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
        end
      end
    end
    

    执行pod install后重新构建项目。

针对启动崩溃问题

从崩溃日志的调用栈可以看出,崩溃发生在UIKit加载主Storyboard的环节,说明iOS项目的启动配置存在异常:

  1. 检查并修复Storyboard配置

    • 打开Xcode中的Runner项目,进入General标签页,确认Main Interface字段为空(纯Flutter项目不需要依赖Storyboard启动)。
    • 打开Info.plist,删除UIMainStoryboardFile键值对,确保应用以Flutter引擎作为启动入口。
  2. 重置iOS构建缓存
    执行以下命令清理并重置项目构建状态:

    flutter clean
    cd ios
    pod deintegrate
    pod install
    cd ..
    flutter run
    

内容的提问来源于stack exchange,提问作者haldiz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 06:18:27