Post

Replies

Boosts

Views

Activity

Issue with Empty Window Appearing on App Launch for macOS App - Help Needed
I've been struggling with a problem for the past couple of weeks, and I can't seem to figure out the cause. I'm developing an app that allows users to easily switch languages on macOS. The app is ready, and I submitted it for review, but the problem is that Apple has been unable to approve it for the past two weeks due to an issue. Upon launching the app, an empty window/container appears, but I cannot reproduce this issue on my own Macs (M1, M2, M3). On my machines, the app works perfectly and launches without the empty window appearing. Does anyone know how I can identify and resolve this issue? I’ve attached a screenshot of the empty window that needs to be removed from the code, as well as a snippet of the code that might be responsible for it. I would greatly appreciate any advice or suggestions on how to fix this, as I’m unable to reproduce the error on my end. Thanks in advance for your help! @main struct LanguageSwitcherApp: App { @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate var body: some Scene { Settings { EmptyView() } .commands { CommandGroup(after: .appInfo) { Button("Show Language Switcher") { appDelegate.showLanguageSwitcher() } } } } } class AppDelegate: NSObject, NSApplicationDelegate { private var statusItem: NSStatusItem? private var languageSwitcherPanel: LanguageSwitchPanel? func applicationDidFinishLaunching(_ notification: Notification) { statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) if let button = statusItem?.button { button.image = NSImage(named: "icon_top") button.action = #selector(showMenu) button.target = self } showLanguageSwitcher() } @objc private func showMenu() { let menu = NSMenu() menu.addItem(NSMenuItem(title: "Close Type Switch", action: #selector(closeApp), keyEquivalent: "q")) statusItem?.menu = menu statusItem?.button?.performClick(nil) statusItem?.menu = nil } func showLanguageSwitcher() { guard languageSwitcherPanel == nil else { return } let panel = LanguageSwitchPanel() let hostingController = NSHostingController(rootView: LanguageSwitchView()) panel.contentView = hostingController.view panel.makeKeyAndOrderFront(nil) NSApp.activate(ignoringOtherApps: true) languageSwitcherPanel = panel } @objc private func closeApp() { NSApp.terminate(nil) } } Screenshot: https://ibb.co/hynrgyw I tried testing the app on my MacBook models (M1, M2, M3) and all of them functioned as expected, launching the app without any additional windows appearing. I also checked the code for any unintended window launches or containers and could not find any issues. I expected the app to launch without any extra empty windows or containers, but when Apple tested it, they encountered an issue with an empty window appearing upon launch.
2
0
69
1d