When I run my Flutter app on the iOS simulator for the first time, the app installs successfully but crashes immediately upon launch with the following error:
Xcode build done. 72.5s
[ERROR:flutter/shell/platform/darwin/graphics/FlutterDarwinContextMetalImpeller.mm(42)] Using the Impeller rendering backend.
Debug service listening on ws://127.0.0.1:62219/w_wwbsEeRJU=/ws
Syncing files to device iPhone 15 Pro Max...
flutter: PHRASE OTA: Cache for `en` not found
flutter: OTA Request URL: https://ota.eu.phrase.com/f286a9f5799faca020be7e2aec96f66e/rxq-BbiTPn4AZpJV5ND2VXHZ8Iz2zq5LkFe8gVfsqeU/en/arb?client=flutter&sdk_version=1.0.5&unique_identifier=7e5418f7-e595-4044-b3fd-4097f3b21eee&app_version=1.11.0
[App Start] null
[XXXMobileBloc] Change { currentState: XXXMobileState(authStatus: AuthStatus.unknown, privacyStatusAccepted: false, personalDetailsValid:...
Lost connection to device.
Error: Unable to terminate com.XXX.XXX.dev on E0B08135-8683-47D1-8AEE-FF0276B56AD7:
ProcessException: Process exited abnormally with exit code 3:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=3):
Simulator device failed to terminate com.XXX.XXX.dev.
found nothing to terminate
Underlying error (domain=NSPOSIXErrorDomain, code=3):
The request to terminate "com.XXX.XXX.dev" failed. found nothing to terminate
found nothing to terminate
Command: /usr/bin/arch -arm64e xcrun simctl terminate E0B08135-8683-47D1-8AEE-FF0276B56AD7 com.XXX.XXX.dev
Failed to send request: {"jsonrpc":"2.0","id":"27","method":"getObject","params":{"isolateId":"isolates/8832513557008815","objectId":"objects/5","offset":0,"count":1564}}
the Dart compiler exited unexpectedly.
[GoRouter] null
[GoRouter] setting initial location /
[XXXMobileBloc] null
However, if I then launch the app directly from the simulator by clicking its icon, or if I run it again from the IDE, it starts without any issues.
I only encounter this problem on the iOS simulator. The app runs without any issues on the Android simulator and on real devices for both Android and iOS.
Any insights on why this issue occurs on the first run and how to fix it?