瀏覽代碼

Fix App Review Guideline 4.0 by quitting when the main window closes.

Apple rejected the prior Window-menu reopen approach and recommended that single-window apps terminate on close instead. Stop hiding the main window with orderOut, remove the custom Window reopen menu item, and return true from applicationShouldTerminateAfterLastWindowClosed so closing the last window quits the app. Also bump the build number and align sandbox project/entitlement settings for the App Store resubmission.

Co-authored-by: Cursor <cursoragent@cursor.com>
Uzair Tahir 1 周之前
父節點
當前提交
4eb6c45e7d

+ 24 - 4
smart_printer.xcodeproj/project.pbxproj

@@ -253,10 +253,20 @@
 				CODE_SIGN_ENTITLEMENTS = smart_printer/smart_printer.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
-				CURRENT_PROJECT_VERSION = 1;
+				CURRENT_PROJECT_VERSION = 3;
 				DEVELOPMENT_TEAM = GYWNF5WK4J;
 				ENABLE_APP_SANDBOX = YES;
-				ENABLE_USER_SELECTED_FILES = readonly;
+				ENABLE_INCOMING_NETWORK_CONNECTIONS = NO;
+				ENABLE_OUTGOING_NETWORK_CONNECTIONS = NO;
+				ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = NO;
+				ENABLE_RESOURCE_ACCESS_BLUETOOTH = NO;
+				ENABLE_RESOURCE_ACCESS_CALENDARS = NO;
+				ENABLE_RESOURCE_ACCESS_CAMERA = NO;
+				ENABLE_RESOURCE_ACCESS_CONTACTS = NO;
+				ENABLE_RESOURCE_ACCESS_LOCATION = NO;
+				ENABLE_RESOURCE_ACCESS_PRINTING = NO;
+				ENABLE_RESOURCE_ACCESS_USB = NO;
+				ENABLE_USER_SELECTED_FILES = readwrite;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AppInfo.plist;
 				INFOPLIST_KEY_CFBundleDisplayName = "Printer App - All Printers";
@@ -299,10 +309,20 @@
 				CODE_SIGN_ENTITLEMENTS = smart_printer/smart_printer.entitlements;
 				CODE_SIGN_STYLE = Automatic;
 				COMBINE_HIDPI_IMAGES = YES;
-				CURRENT_PROJECT_VERSION = 1;
+				CURRENT_PROJECT_VERSION = 3;
 				DEVELOPMENT_TEAM = GYWNF5WK4J;
 				ENABLE_APP_SANDBOX = YES;
-				ENABLE_USER_SELECTED_FILES = readonly;
+				ENABLE_INCOMING_NETWORK_CONNECTIONS = NO;
+				ENABLE_OUTGOING_NETWORK_CONNECTIONS = NO;
+				ENABLE_RESOURCE_ACCESS_AUDIO_INPUT = NO;
+				ENABLE_RESOURCE_ACCESS_BLUETOOTH = NO;
+				ENABLE_RESOURCE_ACCESS_CALENDARS = NO;
+				ENABLE_RESOURCE_ACCESS_CAMERA = NO;
+				ENABLE_RESOURCE_ACCESS_CONTACTS = NO;
+				ENABLE_RESOURCE_ACCESS_LOCATION = NO;
+				ENABLE_RESOURCE_ACCESS_PRINTING = NO;
+				ENABLE_RESOURCE_ACCESS_USB = NO;
+				ENABLE_USER_SELECTED_FILES = readwrite;
 				GENERATE_INFOPLIST_FILE = YES;
 				INFOPLIST_FILE = AppInfo.plist;
 				INFOPLIST_KEY_CFBundleDisplayName = "Printer App - All Printers";

+ 1 - 30
smart_printer/AppDelegate.swift

@@ -23,7 +23,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
         resolveMainWindowController()
         configureMainWindow()
         configurePreferencesMenu()
-        configureWindowMenu()
         observeContactChanges()
         prefetchContactsIfAuthorized()
         NSApp.activate(ignoringOtherApps: true)
@@ -70,36 +69,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
         preferencesItem.action = #selector(showSettings(_:))
     }
 
-    /// Ensures Window > [app name] can reopen the main window after it is closed.
-    private func configureWindowMenu() {
-        guard let windowMenu = NSApp.windowsMenu
-            ?? NSApp.mainMenu?.item(withTitle: "Window")?.submenu else { return }
-
-        let title = AppStoreConfig.displayName
-        if let existing = windowMenu.items.first(where: {
-            $0.title == title || $0.action == #selector(showMainWindow(_:))
-        }) {
-            existing.title = title
-            existing.target = self
-            existing.action = #selector(showMainWindow(_:))
-            if existing.keyEquivalent.isEmpty {
-                existing.keyEquivalent = "0"
-            }
-            return
-        }
-
-        let showItem = NSMenuItem(
-            title: title,
-            action: #selector(showMainWindow(_:)),
-            keyEquivalent: "0"
-        )
-        showItem.target = self
-        windowMenu.insertItem(showItem, at: 0)
-        windowMenu.insertItem(.separator(), at: 1)
-    }
-
     func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
-        false
+        true
     }
 
     func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {

+ 0 - 6
smart_printer/Base.lproj/Main.storyboard

@@ -634,12 +634,6 @@
                                 <modifierMask key="keyEquivalentModifierMask"/>
                                 <menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
                                     <items>
-                                        <menuItem title="Printer App - All Printers" keyEquivalent="0" id="SpW-Mn-Rw1">
-                                            <connections>
-                                                <action selector="showMainWindow:" target="Voe-Tx-rLC" id="SpW-Ac-001"/>
-                                            </connections>
-                                        </menuItem>
-                                        <menuItem isSeparatorItem="YES" id="SpW-Sep-001"/>
                                         <menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
                                             <connections>
                                                 <action selector="performMiniaturize:" target="Ady-hI-5gd" id="VwT-WD-YPe"/>

+ 1 - 11
smart_printer/MainWindowController.swift

@@ -5,14 +5,4 @@
 
 import Cocoa
 
-final class MainWindowController: NSWindowController, NSWindowDelegate {
-    override func windowDidLoad() {
-        super.windowDidLoad()
-        window?.delegate = self
-    }
-
-    @objc func windowShouldClose(_ sender: NSWindow) -> Bool {
-        sender.orderOut(nil)
-        return false
-    }
-}
+final class MainWindowController: NSWindowController {}

+ 2 - 6
smart_printer/smart_printer.entitlements

@@ -4,15 +4,11 @@
 <dict>
 	<key>com.apple.security.app-sandbox</key>
 	<true/>
-	<key>com.apple.security.files.user-selected.read-write</key>
-	<true/>
-	<key>com.apple.security.files.downloads.read-write</key>
-	<true/>
 	<key>com.apple.security.network.client</key>
 	<true/>
-	<key>com.apple.security.print</key>
-	<true/>
 	<key>com.apple.security.personal-information.addressbook</key>
 	<true/>
+	<key>com.apple.security.print</key>
+	<true/>
 </dict>
 </plist>