diff --git a/App/App_macOS.swift b/App/App_macOS.swift index 8710091f..55e49ce8 100644 --- a/App/App_macOS.swift +++ b/App/App_macOS.swift @@ -157,6 +157,12 @@ struct RootView: View { navigation.currentItem = .reading browser.load(url: url) } + .onReceive(NotificationCenter.default.publisher(for: NSWindow.willCloseNotification), perform: { output in + guard let window = output.object as? NSWindow else { return } + if window.isKeyWindow && window.isMainWindow { // if this is the very last window, close the app + NSApp.terminate(nil) + } + }) .onReceive(appTerminates) { _ in browser.persistAllTabIdsFromWindows() }.task { diff --git a/project.yml b/project.yml index 89281f3e..ee578fb9 100644 --- a/project.yml +++ b/project.yml @@ -65,7 +65,6 @@ targetTemplates: path: Support/Kiwix.entitlements properties: com.apple.security.app-sandbox: true - com.apple.security.files.downloads.read-write: true com.apple.security.files.user-selected.read-only: true com.apple.security.network.client: true dependencies: @@ -92,6 +91,9 @@ targets: Kiwix: templates: - ApplicationTemplate + entitlements: + properties: + com.apple.security.files.downloads.read-write: true settings: base: MARKETING_VERSION: "3.3.0"