Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

AppKit: presentAsModalWindow doesn't center the presented window on macOS 15

When I present a view controller, whose view is a SwiftUI View, via presentAsModalWindow(_:) the presented window is no longer centered horizontally to the screen, but rather its origin is there. I know this issue occurs for macOS 15.2+, but can't tell if it is from 15.0+. I couldn't find any documentation on why was this changed.

Here's an example code that represents my architecture:

class RootViewController: NSViewController {
  private lazy var button: NSButton = NSButton(
    title: "Present",
    target: self,
    action: #selector(presentView))

  override func viewDidLoad() {
    super.viewDidLoad()
    // Add button to tree
  }

  @objc func presentView() {
    presentAsModalWindow(PresentedViewController())
  }
}

class PresentedViewController: NSViewController {
  override loadView() {
    view = NSHostingView(rootView: MyView())
  }
}

struct MyView: View {
  /* impl */
}
AppKit: presentAsModalWindow doesn't center the presented window on macOS 15
 
 
Q