Repository: flutter
Issue: embedding Mac frameworks crashes with an exception
Labels: c: crash,engine,platform-mac,a: existing-apps,a: desktop,has reproducible steps,P2,found in release: 3.10,found in release: 3.11,team-macos,triaged-macos

### 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. create a basic flutter app: `flutter create basic_app`
2. from the flutter app, build mac frameworks: `flutter build macos-framework`
3. create an XCode app
4. insert the two previously built frameworks (FlutterMacOS & App) to the XCode app (I had to add an explicit copy step to codesign the added frameworks)
5. add a Swift Window class with the skeleton described in FlutterViewController.h (example code below)
6. in the storyboard, assign the above window class to the main window
7. try to run the XCode app; it will stop with an exception where the FlutterViewController is created

I tried the same thing with a previous flutter version (iirc, ca. 2 months ago) and back then it worked as expected. I'm using the latest MacOS (13.4) and the latest XCode (14.3), but the same happened with an older MacOS (12.x)

### Expected results

FlutterViewController being created without exception

### Actual results

When creating the view controller (`let flutterViewController = FlutterViewController()`), an exception is raised and the program stops. The exception says 

 "-[MacApp4.AppDelegate setTerminationHandler:]: unrecognized selector sent to instance 0x600003c3c000"

### Code sample

<details><summary>Code sample</summary>

```
import Cocoa
import FlutterMacOS

class MainFlutterWindow: NSWindow {
  override func awakeFromNib() {
    let flutterViewController = FlutterViewController()
    let windowFrame = self.frame
    self.contentViewController = flutterViewController
    self.setFrame(windowFrame, display: true)

    //RegisterGeneratedPlugins(registry: flutterViewController)

    super.awakeFromNib()
  }
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]
![CA83DFD1-ECA9-412B-9100-76DDC0029AB7](https://github.com/flutter/flutter/assets/15326154/6c10bee6-e1f9-4c04-9250-d381507ddb18)


</details>


### Logs

<details><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.1, on macOS 13.4 22F66 darwin-x64, locale de-DE)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[!] Android Studio (not installed)
[✓] VS Code (version 1.78.2)
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 2 categories.
```

</details>