Open cbenhagen opened 8 months ago
Related to https://github.com/macosui/macos_ui/issues/450. I am aware of the issue, but haven’t had much time to work on it lately.
EDIT: Thanks for finding out which commit is causing the issue, though. This might help with investigating the issue.
I am using the old instructions as a workaround and can confirm that the example now works from macOS 10.15.7 to 14.2.1:
Open the macos/Runner.xcworkspace
folder of your project using Xcode, press ⇧ + ⌘ + O and search for MainFlutterWindow.swift
.
Insert import macos_window_utils
at the top of the file.
Then, replace the code above the super.awakeFromNib()
-line with the following code:
let windowFrame = self.frame
let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
self.contentViewController = macOSWindowUtilsViewController
self.setFrame(windowFrame, display: true)
/* Initialize the macos_window_utils plugin */
MainFlutterWindowManipulator.start(mainFlutterWindow: self)
RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)
Assuming you're starting with the default configuration, the finished code should look something like this:
import Cocoa
import FlutterMacOS
+import macos_window_utils
class MainFlutterWindow: NSWindow {
override func awakeFromNib() {
- let flutterViewController = FlutterViewController.init()
- let windowFrame = self.frame
- self.contentViewController = flutterViewController
- self.setFrame(windowFrame, display: true)
- RegisterGeneratedPlugins(registry: flutterViewController)
+ let windowFrame = self.frame
+ let macOSWindowUtilsViewController = MacOSWindowUtilsViewController()
+ self.contentViewController = macOSWindowUtilsViewController
+ self.setFrame(windowFrame, display: true)
+ /* Initialize the macos_window_utils plugin */
+ MainFlutterWindowManipulator.start(mainFlutterWindow: self)
+ RegisterGeneratedPlugins(registry: macOSWindowUtilsViewController.flutterViewController)
super.awakeFromNib()
}
}
Thank you! The workaround seems to work.
Running the example in this repo renders an empty window on macOS 12.7.1 and 10.15.7 (both running on Intel) but works as expected on an Apple Silicon machine with macOS 14.2.1:
I first tested older Flutter versions and then older versions of this repo. Using git bisect I was able to track it down to this one commit: 9f09f88fd8551482fcc1fd7297d9a42fd00cdf09
So I am guessing the changes in 24fe66e47d5029e0bd11709acf931e099b8c2dde somehow only work for newer macOS versions? @Adrian-Samoticha do you have any ideas why this might be the case and how to fix it?