Skip to content

embedding Mac frameworks crashes with an exception #127476

@woolfman007

Description

@woolfman007

Is there an existing issue for this?

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

Code sample
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()
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]
CA83DFD1-ECA9-412B-9100-76DDC0029AB7

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopa: existing-appsIntegration with existing apps via the add-to-app flowc: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.found in release: 3.10Found to occur in 3.10found in release: 3.11Found to occur in 3.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-macBuilding on or for macOS specificallyteam-macosOwned by the macOS platform teamtriaged-macosTriaged by the macOS platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions