Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
fix(setup): plain-language Rosetta and App Management errors, read Downloads only when needed
raymondchinsca18e42c5ff5
diff --git a/app/Sources/NotProtonApp/Model/SetupChecks.swift b/app/Sources/NotProtonApp/Model/SetupChecks.swiftindex 6368c38..e6b2acc 100644--- a/app/Sources/NotProtonApp/Model/SetupChecks.swift+++ b/app/Sources/NotProtonApp/Model/SetupChecks.swift@@ -46,6 +46,19 @@ enum SetupChecks {try Shell.check("/usr/bin/osascript", ["-e", script])}+ // osascript's own error text ("execution error: User canceled. (-128)") means nothing to+ // most people, so the two common cases get plain sentences.+ static func rosettaFailure(_ error: Error) -> String {+ let text = error.localizedDescription+ if text.contains("(-128)") || text.localizedCaseInsensitiveContains("user canceled") {+ return String(localized: "Rosetta wasn't installed because the password window was closed. Press Install to try again.")+ }+ if text.contains("(-60005)") || text.contains("(-60007)") {+ return String(localized: "Rosetta wasn't installed because macOS didn't accept the password. Use the name and password of an administrator of this Mac.")+ }+ return String(localized: "Rosetta wasn't installed. Check your internet connection and try again.")+ }+static var loginUsers: URL {SupportPaths.Steam.userData.appending(path: "config/loginusers.vdf")}@@ -92,6 +105,12 @@ enum DiskImage {enum GPTKImport {static var downloads: URL { SupportPaths.home.appending(path: "Downloads", directoryHint: .isDirectory) }+ // Downloads is only read while no Game Porting Toolkit is installed, so a Mac that has one+ // never sees the Downloads folder access prompt.+ static func candidatesIfMissing(installed: Bool, scan: () -> [URL] = { candidates() }) -> [URL] {+ installed ? [] : scan()+ }+// Apple names the image Game_Porting_Toolkit_<version>.dmg; the newest name sorts last.static func candidates(in folder: URL = downloads) -> [URL] {let names = (try? FileManager.default.contentsOfDirectory(atPath: folder.path(percentEncoded: false))) ?? []diff --git a/app/Sources/NotProtonApp/Support/WriteRefused.swift b/app/Sources/NotProtonApp/Support/WriteRefused.swiftindex f856315..63c70bb 100644--- a/app/Sources/NotProtonApp/Support/WriteRefused.swift+++ b/app/Sources/NotProtonApp/Support/WriteRefused.swift@@ -34,7 +34,10 @@ enum Remedy: Hashable {var advice: String {switch self {- case .appManagement: String(localized: "Bridgeplay needs the App Management permission.")+ // macOS ties the permission to the app's signature, so after an update the switch can+ // stay on while no longer applying.+ case .appManagement:+ String(localized: "Bridgeplay needs the App Management permission. Turn on Bridgeplay in System Settings › Privacy & Security › App Management. After a Bridgeplay update the switch can look on but no longer work: turn it off and on again.")case .otherAccount:String(localized: "Steam was installed by another account on this Mac. Only that account can modify it. Log in to macOS with that account to reinstall Bridgeplay.")case .ownership: String(localized: "Check permissions, make sure your user owns the folder.")diff --git a/app/Tests/NotProtonAppTests/SetupAssistantTests.swift b/app/Tests/NotProtonAppTests/SetupAssistantTests.swiftindex a39e241..48d3ca2 100644--- a/app/Tests/NotProtonAppTests/SetupAssistantTests.swift+++ b/app/Tests/NotProtonAppTests/SetupAssistantTests.swift@@ -75,3 +75,35 @@ struct SetupAssistantTests {#expect(!SetupAssistant.shouldShow(nil, defaults: defaults))}}++@Suite("Setup checks")+struct SetupChecksTests {++ @Test("Downloads is not read when a Game Porting Toolkit is already installed")+ func downloadsScanGated() {+ var scans = 0+ let scan: () -> [URL] = { scans += 1; return [URL(filePath: "/Downloads/Game_Porting_Toolkit_3.0.dmg")] }+ #expect(GPTKImport.candidatesIfMissing(installed: true, scan: scan).isEmpty)+ #expect(scans == 0)+ #expect(GPTKImport.candidatesIfMissing(installed: false, scan: scan).count == 1)+ #expect(scans == 1)+ }++ @Test("Rosetta failures read as plain sentences")+ func rosettaMessages() {+ let cancelled = CommandFailure(command: "osascript", status: 1, stderr: "0:120: execution error: User canceled. (-128)")+ #expect(SetupChecks.rosettaFailure(cancelled).contains("password window was closed"))+ let denied = CommandFailure(command: "osascript", status: 1, stderr: "execution error: The administrator user name or password was incorrect. (-60005)")+ #expect(SetupChecks.rosettaFailure(denied).contains("administrator"))+ let other = CommandFailure(command: "osascript", status: 1, stderr: "softwareupdate: network down")+ let message = SetupChecks.rosettaFailure(other)+ #expect(!message.contains("osascript"))+ #expect(message.contains("internet"))+ }++ @Test("The App Management advice explains the switch that looks on after an update")+ func appManagementAdvice() {+ #expect(Remedy.appManagement.advice.contains("App Management"))+ #expect(Remedy.appManagement.advice.contains("off and on again"))+ }+}