Repository: flutter
Issue: Flutter IOS debug build installs the app on a real device but fails to initialize dart VM server
Labels: c: crash,platform-ios,tool,P2,team-ios,triaged-ios

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. Connect your IPad/IPhone with cable with MacBook m1 pro 
2. Build with VS-code with default settings.

### Actual results

But when I try to install on the device with XCode or with simulator, it builds and works fine. I tried solutions on the the [link](https://stackoverflow.com/questions/69140504/ios-observatory-not-discovered-after-30-seconds-error-launching-application-on) on stackoverflow with different issue, but none of them have no avail to fix the problem.

I have tried with IPad pro 11 inch 2020 and IPhone 11 pro with the same WIFI network. And I am using Macbook M1 pro 14 inch 2021 base model. I've been using real IOS devices for more than a year with the same project. But about a month ago it started giving me the error.

When I try to build with a real device, the app doesn't ask local network permission nor notification permission. I've tried with different projects and it had the same error. Also I created a new flutter project with 0 dependencies, it gave me the same error but after I ran the app with XCode for two times it started working. But after I added dependencies from the first project that I ran into problem with, I started getting the same error. But the weird thing is when I use Flutter release mode, it works fine with any project. (By the way I have enabled wireless debug on XCode with both of the real devices I have mentioned earlier. But no difference with debug builds.)

XCode version : Version 14.3 (14E222b)

### Logs

<details>
<summary>Logs</summary>

```console

[  +52 ms] [ 95%] GeneratingApplicationMap
[ +327 ms] [100%] InstallComplete
[ +987 ms] [100%] Installed package build/ios/iphoneos/Runner.app
[  +99 ms] ------ Debug phase ------
[        ] Starting debug of 00008027-000C684A0A08402E (J418AP, iPad Pro 2G (11" Cell), iphoneos, arm64e, 16.4.1, 20E252) a.k.a. 'Gantushig’s iPad' connected
through USB...
[+1026 ms] [  0%] Looking up developer disk image
[  +27 ms] [ 95%] Developer disk image mounted successfully
[  +23 ms] Symbol Path: /Users/gantushig/Library/Developer/Xcode/iOS DeviceSupport/16.4.1 (20E252) arm64e/Symbols
[ +457 ms] [100%] Connecting to remote debug server
[        ] -------------------------
[  +99 ms] (lldb) command source -s 0 '/tmp/B9863F2D-673A-40A5-9D48-5C384D397A22/fruitstrap-lldb-prep-cmds-00008027_000C684A0A08402E'
[        ] Executing commands in '/tmp/B9863F2D-673A-40A5-9D48-5C384D397A22/fruitstrap-lldb-prep-cmds-00008027_000C684A0A08402E'.
[        ] (lldb)     platform select remote-'ios' --sysroot '/Users/gantushig/Library/Developer/Xcode/iOS DeviceSupport/16.4.1 (20E252) arm64e/Symbols'
[        ]   Platform: remote-ios
[        ]  Connected: no
[        ]    Sysroot: /Users/gantushig/Library/Developer/Xcode/iOS DeviceSupport/16.4.1 (20E252) arm64e/Symbols
[        ]   SDK Path: "/Users/gantushig/Library/Developer/Xcode/iOS DeviceSupport/16.4.1 (20E252) arm64e/Symbols"
[        ] (lldb)     target create "/Users/gantushig/projects/soyohon/soyohon_mobile/build/ios/iphoneos/Runner.app"
[+6149 ms] Current executable set to '/Users/gantushig/projects/soyohon/soyohon_mobile/build/ios/iphoneos/Runner.app' (arm64).
[        ] (lldb)     script fruitstrap_device_app="/private/var/containers/Bundle/Application/9191066D-06EC-41D9-A945-7BBDAB5CEBA1/Runner.app"
[        ] (lldb)     script fruitstrap_connect_url="connect://127.0.0.1:59678"
[        ] (lldb)     script fruitstrap_output_path=""
[        ] (lldb)     script fruitstrap_error_path=""
[        ] (lldb)     target modules search-paths add /usr "/Users/gantushig/Library/Developer/Xcode/iOS DeviceSupport/16.4.1 (20E252) arm64e/Symbols/usr"
/System "/Users/gantushig/Library/Developer/Xcode/iOS DeviceSupport/16.4.1 (20E252) arm64e/Symbols/System"
"/private/var/containers/Bundle/Application/9191066D-06EC-41D9-A945-7BBDAB5CEBA1" "/Users/gantushig/projects/soyohon/soyohon_mobile/build/ios/iphoneos"
"/var/containers/Bundle/Application/9191066D-06EC-41D9-A945-7BBDAB5CEBA1" "/Users/gantushig/projects/soyohon/soyohon_mobile/build/ios/iphoneos" /Developer
"/Users/gantushig/Library/Developer/Xcode/iOS DeviceSupport/16.4.1 (20E252) arm64e/Symbols/Developer"
[  +34 ms] (lldb)     command script import "/tmp/B9863F2D-673A-40A5-9D48-5C384D397A22/fruitstrap_00008027_000C684A0A08402E.py"
[   +3 ms] (lldb)     command script add -f fruitstrap_00008027_000C684A0A08402E.connect_command connect
[        ] (lldb)     command script add -s asynchronous -f fruitstrap_00008027_000C684A0A08402E.run_command run
[        ] (lldb)     command script add -s asynchronous -f fruitstrap_00008027_000C684A0A08402E.autoexit_command autoexit
[        ] (lldb)     command script add -s asynchronous -f fruitstrap_00008027_000C684A0A08402E.safequit_command safequit
[        ] (lldb)     connect
[  +32 ms] (lldb)     run
[ +198 ms] success
[        ] Application launched on the device. Waiting for Dart VM Service url.
[+30005 ms] The Dart VM Service was not discovered after 30 seconds. This is taking much longer than expected...
[   +8 ms] (lldb) process interrupt
[        ] error: Failed to halt process: Halt timed out. State = running
[+2073 ms] (lldb) Process 2598 exited with status = -1 (0xffffffff) lost connection
[   +3 ms] ios-deploy exited with code 0
[   +6 ms] Installing and launching... (completed in 56.6s)
[        ] Error launching application on Gantushig’s iPad.
[   +2 ms] "flutter run" took 96,019ms.
[   +3 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:757:9)
           <asynchronous suspension>
           #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1336:27)
           <asynchronous suspension>
           #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #4      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:296:9)
           <asynchronous suspension>
           #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:244:5)
           <asynchronous suspension>
           #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:91:9)
           <asynchronous suspension>
           #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #10     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>
           
           
[ +259 ms] ensureAnalyticsSent: 253ms
[        ] Running 1 shutdown hook
[   +3 ms] Shutdown hooks complete
[        ] exiting with code 1

```

</details>


### Flutter Doctor output

<details>
<summary>Doctor output</summary>

```console

[✓] Flutter (Channel stable, 3.10.1, on macOS 13.3.1 22E772610a darwin-arm64, locale en-MN)
    • Flutter version 3.10.1 on channel stable at /Users/gantushig/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d3d8effc68 (9 days ago), 2023-05-16 17:59:05 -0700
    • Engine revision b4fb11214d
    • Dart version 3.0.1
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/gantushig/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (3 available)
    • Gantushig’s iPad (mobile) • 00008027-000C684A0A08402E • ios            • iOS 16.4.1 20E252
    • macOS (desktop)           • macos                     • darwin-arm64   • macOS 13.3.1 22E772610a darwin-arm64
    • Chrome (web)              • chrome                    • web-javascript • Google Chrome 113.0.5672.126

[✓] Network resources
    • All expected network resources are available.

• No issues found!

```

</details>