Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Send game data: offer the Finder way when the copy is refused

v0lumehife458ac54b86
diff --git a/frontend/Sources/NX2Apple/LauncherStores.swift b/frontend/Sources/NX2Apple/LauncherStores.swift
index 7dca2dad..36e85ba5 100644
--- a/frontend/Sources/NX2Apple/LauncherStores.swift
+++ b/frontend/Sources/NX2Apple/LauncherStores.swift
@@ -119,6 +119,7 @@ import NXModel
a.runModal()
}
build.revealFolder = { NSWorkspace.shared.open($0) }
+ build.revealItem = { NSWorkspace.shared.activateFileViewerSelecting([$0]) }
build.openApp = { NSWorkspace.shared.openApplication(at: $0, configuration: NSWorkspace.OpenConfiguration()) }
}
diff --git a/frontend/Sources/NXCore/DeviceApps.swift b/frontend/Sources/NXCore/DeviceApps.swift
index d255bfb2..95f0d4ab 100644
--- a/frontend/Sources/NXCore/DeviceApps.swift
+++ b/frontend/Sources/NXCore/DeviceApps.swift
@@ -37,17 +37,12 @@ extension ShellInstall {
/// Why the game data could not be put into the app.
package enum DataFailure: Equatable {
- /// The device has no app with this bundle ID.
+ /// The device lists no app with the shared app's bundle ID.
case appNotFound
- /// devicectl refused: an app not signed for development (get-task-allow), no permission, or anything else it says.
+ /// The device's list of apps could not be read (locked, not connected). Nothing was tried on the app yet.
+ case noAppList
+ /// The device listed the app, but the copy into it failed. devicectl's words are in the outcome's `detail`. What we believe,
+ /// not verified on a device: an app that another tool signed does not allow it (no `get-task-allow`) (#491).
case refused
}
-
- /// What a devicectl copy error means. Only a missing app is told apart. Everything else is a refusal, shown with devicectl's words.
- package static func dataFailure(copyError text: String) -> DataFailure {
- let lower = text.lowercased()
- let missing = ["not installed", "no such app", "unknown app", "could not find the app", "couldn't find the app", "application not found",
- "app not found", "no app with"]
- return missing.contains { lower.contains($0) } ? .appNotFound : .refused
- }
}
diff --git a/frontend/Sources/NXCore/ShellExport.swift b/frontend/Sources/NXCore/ShellExport.swift
index 7179f96f..c5c5348a 100644
--- a/frontend/Sources/NXCore/ShellExport.swift
+++ b/frontend/Sources/NXCore/ShellExport.swift
@@ -162,8 +162,9 @@ extension ShellInstaller {
/// The game data into the shared app that is installed already and signed by another tool (LNPANDY/NX2Apple#416). The app is found
/// on the device by its bundle ID prefix (a sideloading tool may add a team ID): none is `.appNotFound`, several come back in
/// `apps` for the player to choose from (`bundleID` then names the one). The copy is the install's own data step (listing, diff,
- /// free space, the wired-or-Wi-Fi question, the copy). devicectl writes into an app container only for an app signed for development
- /// (get-task-allow), so its refusal comes back as `.refused` with its own words in `detail`.
+ /// free space, the wired-or-Wi-Fi question, the copy). A copy that fails comes back as `.refused` with devicectl's words in `detail`.
+ /// We believe devicectl writes into an app container only for an app signed for development (get-task-allow). That is not verified on
+ /// a device, so the launcher says only that the device refused, and offers the Finder way (#491).
package func sendData(titleID: String, archive: String, bundleID: String? = nil) -> Outcome {
if let refused = pairingRefusal() { return refused }
var chosen = bundleID, name = ""
@@ -172,7 +173,10 @@ extension ShellInstaller {
defer { try? FileManager.default.removeItem(atPath: json) }
let listed = run([xcrun, "devicectl"] + InstalledApps.listArguments(device: device, json: json), env: nil, label: t("shell.sendStage"), step: { _ in nil })
guard listed.status == 0, let apps = InstalledApps.parse(FileManager.default.contents(atPath: json) ?? Data()) else {
- return Outcome(ok: false, message: listed.lastError ?? fmt("msg.exitCode", listed.status))
+ var unread = Outcome(ok: false, message: fmt("shell.sendListFailed", deviceName))
+ unread.detail = listed.lastError ?? fmt("msg.exitCode", listed.status)
+ unread.dataFailure = .noAppList
+ return unread
}
let found = ShellInstall.shellApps(in: apps)
guard let first = found.first else {
@@ -194,8 +198,9 @@ extension ShellInstaller {
outcome.message = t("shell.sendDone")
}
if !outcome.ok, outcome.failure == .shellDataIncomplete {
- outcome.dataFailure = ShellInstall.dataFailure(copyError: outcome.detail)
- outcome.message = outcome.dataFailure == .appNotFound ? t("shell.sendNoApp") : t("shell.sendRefused")
+ // The device listed the app, so a copy that fails is a refusal, whatever devicectl's words are (#491). Its words stay in `detail`.
+ outcome.dataFailure = .refused
+ outcome.message = t("shell.sendRefused")
outcome.failure = nil // the install's Retry card does not fit: nothing of the install ran
}
return outcome
diff --git a/frontend/Sources/NXLauncher/ExportSteps.swift b/frontend/Sources/NXLauncher/ExportSteps.swift
index 15da01d8..b7fad066 100644
--- a/frontend/Sources/NXLauncher/ExportSteps.swift
+++ b/frontend/Sources/NXLauncher/ExportSteps.swift
@@ -133,7 +133,7 @@ package struct ExportSteps: View {
case .sent:
note(.done, loc.t("shell.sendDone"))
case .appNotFound:
- note(.warning, loc.t("shell.sendNoApp"))
+ note(.warning, loc.t("shell.sendNoApp")) { finderWay(detail: nil) }
case .chooseApp(let apps):
note(.warning, loc.t("shell.sendSeveral")) {
ForEach(apps, id: \.bundle) { app in
@@ -142,27 +142,7 @@ package struct ExportSteps: View {
}
}
case .refused(let detail):
- note(.warning, loc.t("shell.sendRefused")) {
- Text(loc.t("shell.sendFinderSteps")).font(.manrope(12.5)).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
- HStack(spacing: 16) {
- Button(loc.t("shell.sendShowData")) { build.showGameDataInFinder() }.buttonStyle(LauncherSecondaryButtonStyle())
- Button { withAnimation(.easeInOut(duration: 0.18)) { detailsOpen.toggle() } } label: {
- HStack(spacing: 6) {
- Text(loc.t("shell.sendDetails")).font(.manrope(12.5, .medium))
- Image(systemName: "chevron.right").font(.system(size: 9, weight: .bold)).rotationEffect(.degrees(detailsOpen ? 90 : 0))
- }
- .foregroundStyle(.secondary).contentShape(Rectangle())
- }
- .buttonStyle(.plain).accessibilityAddTraits(detailsOpen ? .isSelected : [])
- }
- if detailsOpen {
- Text(detail).font(.mono(11.5)).foregroundStyle(.secondary).textSelection(.enabled)
- .fixedSize(horizontal: false, vertical: true)
- .padding(.horizontal, 12).padding(.vertical, 9)
- .frame(maxWidth: .infinity, alignment: .leading)
- .background(ExportGrid.well, in: RoundedRectangle(cornerRadius: 9))
- }
- }
+ note(.warning, loc.t("shell.sendRefused")) { finderWay(detail: detail) }
case .failed(let text):
note(.warning, text)
case .idle, .copying, .copied:
@@ -170,6 +150,56 @@ package struct ExportSteps: View {
}
}
+ /// The second way, offered only after the copy to the device did not work (#491): one button that opens a Finder window with the
+ /// game's folder selected and then shows the three steps of the drag. devicectl's own words stay behind Details.
+ @ViewBuilder private func finderWay(detail: String?) -> some View {
+ let words = detail.flatMap { $0.isEmpty ? nil : $0 }
+ HStack(spacing: 16) {
+ Button(loc.t("shell.sendFinder")) { withAnimation(.easeInOut(duration: 0.18)) { build.copyWithFinder(oneGame: oneGame) } }
+ .buttonStyle(LauncherSecondaryButtonStyle())
+ if words != nil {
+ Button { withAnimation(.easeInOut(duration: 0.18)) { detailsOpen.toggle() } } label: {
+ HStack(spacing: 6) {
+ Text(loc.t("shell.sendDetails")).font(.manrope(12.5, .medium))
+ Image(systemName: "chevron.right").font(.system(size: 9, weight: .bold)).rotationEffect(.degrees(detailsOpen ? 90 : 0))
+ }
+ .foregroundStyle(.secondary).contentShape(Rectangle())
+ }
+ .buttonStyle(.plain).accessibilityAddTraits(detailsOpen ? .isSelected : [])
+ }
+ }
+ if build.finderShown { finderSteps }
+ if detailsOpen, let words {
+ Text(words).font(.mono(11.5)).foregroundStyle(.secondary).textSelection(.enabled)
+ .fixedSize(horizontal: false, vertical: true)
+ .padding(.horizontal, 12).padding(.vertical, 9)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(ExportGrid.well, in: RoundedRectangle(cornerRadius: 9))
+ }
+ }
+
+ /// The drag in three steps, numbered as the export's own steps but smaller, in a well under the button. The folder is the one the
+ /// Finder window shows selected. Step 3 names the shell's own button, in the language the shell shows it.
+ private var finderSteps: some View {
+ let folder = (build.archivePath as NSString).lastPathComponent
+ let choose = L10n.string("ios.ui.chooseGameData", loc.lang).trimmingCharacters(in: CharacterSet(charactersIn: "…. "))
+ let lines = [loc.t("shell.sendFinderStep1"), String(format: loc.t("shell.sendFinderStep2"), folder),
+ String(format: loc.t("shell.sendFinderStep3"), choose, folder)]
+ return VStack(alignment: .leading, spacing: 9) {
+ ForEach(Array(lines.enumerated()), id: \.offset) { index, line in
+ HStack(alignment: .firstTextBaseline, spacing: 10) {
+ Text("\(index + 1)").font(.manrope(11, .semibold)).monospacedDigit().foregroundStyle(.secondary)
+ .frame(width: 18, height: 18).background(Circle().fill(Color.white.opacity(0.08)))
+ Text(line).font(.manrope(12.5)).foregroundStyle(.primary.opacity(0.85)).fixedSize(horizontal: false, vertical: true)
+ }
+ }
+ }
+ .padding(.horizontal, 12).padding(.vertical, 11)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .background(ExportGrid.well, in: RoundedRectangle(cornerRadius: 9))
+ .accessibilityElement(children: .combine)
+ }
+
// MARK: To a drive or folder
private var driveRow: some View {
@@ -236,7 +266,7 @@ package struct ExportSteps: View {
case .copying: send = "copying"
case .copied: send = "copied"
}
- return devices.sendWhere + send + (build.drive.map { "\($0.problem == nil)" } ?? "") + "\(detailsOpen)"
+ return devices.sendWhere + send + (build.drive.map { "\($0.problem == nil)" } ?? "") + "\(detailsOpen)\(build.finderShown)"
}
private enum NoteKind { case done, info, warning, blocked }
diff --git a/frontend/Sources/NXModel/BuildStore+Send.swift b/frontend/Sources/NXModel/BuildStore+Send.swift
index afc83f6d..08cd96aa 100644
--- a/frontend/Sources/NXModel/BuildStore+Send.swift
+++ b/frontend/Sources/NXModel/BuildStore+Send.swift
@@ -12,11 +12,11 @@ package enum DataSend: Equatable {
case sending(done: Int64, total: Int64, note: String)
/// The game data is in the app named `app`.
case sent(app: String)
- /// The device lists no copy of the shared app: install the IPA first.
+ /// The device lists no copy of the shared app: install the IPA first, or copy with Finder when another tool installed it under its own ID.
case appNotFound
/// Several copies of the shared app: the player picks one.
case chooseApp([InstalledApp])
- /// devicectl refused. `detail` is its own text, for a bug report.
+ /// The device listed the app but refused the copy. `detail` is devicectl's own text, for a bug report. The Finder way is offered.
case refused(detail: String)
/// Anything else the copy said (the device is locked, not connected, out of space).
case failed(String)
@@ -26,6 +26,27 @@ package enum DataSend: Equatable {
case copied(folder: String)
}
+extension DataSend {
+ /// What step 3 shows when a send to the device ended. `notConnected` is the text for a device that was not connected, so nothing was
+ /// copied. A refusal and an app the device does not list are their own states, which offer the Finder way (#491). Every other failure
+ /// shows the copy's own sentence (no space, the app list could not be read).
+ package static func after(_ result: ShellInstaller.Outcome, notConnected: String) -> DataSend {
+ if result.copySkipped { return .failed(notConnected) }
+ if result.ok { return .sent(app: result.appName) }
+ if !result.apps.isEmpty { return .chooseApp(result.apps) }
+ switch result.dataFailure {
+ case .appNotFound: return .appNotFound
+ case .refused: return .refused(detail: result.detail)
+ case .noAppList, nil: return .failed(result.message)
+ }
+ }
+
+ /// The copy to the device did not work and Finder can do it: the second way, offered only now.
+ package var offersFinder: Bool {
+ switch self { case .appNotFound, .refused: return true; default: return false }
+ }
+}
+
/// The chosen drive folder as the card shows it: its volume, the size the game data needs, and what stops the copy.
package struct DriveState: Equatable {
package var volume: DriveCopy.Volume?
@@ -88,28 +109,24 @@ extension BuildStore {
self.resetProgress(); self.send = .idle; self.doneNote = self.t("msg.stopped")
return
}
- if result.ok && !result.copySkipped {
- self.send = .sent(app: result.appName.isEmpty ? "" : result.appName)
- } else if result.copySkipped {
- self.send = .failed(String(format: self.t("shell.copyNotConnected"), self.devices.deviceName(device)))
- } else if !result.apps.isEmpty {
- self.send = .chooseApp(result.apps)
- } else if result.dataFailure == .appNotFound {
- self.send = .appNotFound
- } else if result.dataFailure == .refused {
- self.send = .refused(detail: result.detail)
- } else {
- if let kind = result.failure { self.failure = BuildFailure(kind: kind, gameName: nil) }
- self.send = .failed(result.message)
- }
+ self.send = .after(result, notConnected: String(format: self.t("shell.copyNotConnected"), self.devices.deviceName(device)))
+ if case .failed = self.send, !result.copySkipped, let kind = result.failure { self.failure = BuildFailure(kind: kind, gameName: nil) }
}
}
}
- /// Opens the game's data folder in the Finder, for the way that needs no devicectl.
- package func showGameDataInFinder() {
- guard !archivePath.isEmpty else { return }
- revealFolder(URL(fileURLWithPath: archivePath))
+ /// What the player drags onto the app in Finder: the game's folder, named after its title ID, with `romfs.img` and the add-on content
+ /// beside it, as the copy to the device sends them. The folder and not the image alone, so the add-on content comes along and the
+ /// shell's data picker, which picks folders, can pick it. None for one game's own IPA, which holds its data, and before a build packed it.
+ package static func finderItem(archive: String, oneGame: Bool) -> String? {
+ oneGame || archive.isEmpty ? nil : archive
+ }
+
+ /// The Finder way, after the copy to the device did not work: a Finder window with the game's folder selected, ready to drag.
+ package func copyWithFinder(oneGame: Bool) {
+ guard send.offersFinder, let item = Self.finderItem(archive: archivePath, oneGame: oneGame) else { return }
+ revealItem(URL(fileURLWithPath: item))
+ finderShown = true
}
// MARK: To a drive or folder
diff --git a/frontend/Sources/NXModel/BuildStore.swift b/frontend/Sources/NXModel/BuildStore.swift
index 6f142ab2..44a7101c 100644
--- a/frontend/Sources/NXModel/BuildStore.swift
+++ b/frontend/Sources/NXModel/BuildStore.swift
@@ -136,7 +136,11 @@ func hop(_ body: @escaping @MainActor () -> Void) {
@Published package var installedOn = "" // the device the last build went to (its UDID)
@Published package var installedAppPath = "" // the signed app that went there
@Published package var exportedIPAPath = "" // the unsigned IPA of an export (#416)
- @Published package var send: DataSend = .idle // step 3 of the export: the game data on its way (BuildStore+Send.swift)
+ @Published package var send: DataSend = .idle { // step 3 of the export: the game data on its way (BuildStore+Send.swift)
+ didSet { if send != oldValue { finderShown = false } }
+ }
+ /// The player chose the Finder way after the copy to the device did not work: step 3 shows its three steps (#491).
+ @Published package var finderShown = false
@Published package var drive: DriveState? // the chosen folder's volume and what stops the copy (BuildStore+Send.swift)
var shellRetry: (framework: String, titleID: String, name: String, archive: String)?
var shellDeviceChecked = false
@@ -153,6 +157,8 @@ func hop(_ body: @escaping @MainActor () -> Void) {
/// A notice the player must see (the shader chain changed): an alert.
package var showNotice: (String) -> Void = { _ in }
package var revealFolder: (URL) -> Void = { _ in }
+ /// A Finder window with this file or folder selected (`activateFileViewerSelecting`).
+ package var revealItem: (URL) -> Void = { _ in }
package var openApp: (URL) -> Void = { _ in }
/// Whether the build folder is in a cloud folder. Tests stand in for the system's answer.
package var cloudFolderCheck: (String) -> Bool = { CloudFolder.contains($0) }
diff --git a/frontend/Tests/NX2AppleTests/ShellExportCaptureTests.swift b/frontend/Tests/NX2AppleTests/ShellExportCaptureTests.swift
index d7e85ef6..6d4ee7b4 100644
--- a/frontend/Tests/NX2AppleTests/ShellExportCaptureTests.swift
+++ b/frontend/Tests/NX2AppleTests/ShellExportCaptureTests.swift
@@ -72,6 +72,8 @@ final class ShellExportCaptureTests: XCTestCase {
try shot("5-app-not-found", card())
model.send = .refused(detail: "ERROR: Failed to copy: the app does not allow access to its data container (get-task-allow). (com.apple.dt.CoreDeviceError error 7)")
try shot("6-refused", card())
+ model.finderShown = true // after Copy with Finder (#491)
+ try shot("6a-refused-finder", card())
model.send = .chooseApp([InstalledApp(bundle: "org.nxnative.shell.ABCDE12345", name: "NX2Apple"),
InstalledApp(bundle: "org.nxnative.shell", name: "NX2Apple")])
try shot("6b-choose-app", card())
diff --git a/frontend/Tests/NX2AppleTests/ShellExportTests.swift b/frontend/Tests/NX2AppleTests/ShellExportTests.swift
index 735f2c41..23addfd7 100644
--- a/frontend/Tests/NX2AppleTests/ShellExportTests.swift
+++ b/frontend/Tests/NX2AppleTests/ShellExportTests.swift
@@ -89,10 +89,14 @@ import NXModel
sys.exit(1) # no shell log
elif a[:4] == ['devicectl', 'device', 'copy', 'to']:
if os.path.exists('\(state)/refuse'):
- print('ERROR: Failed to copy: the app does not allow access to its data container (get-task-allow). (com.apple.dt.CoreDeviceError error 7)', flush=True)
+ words = open('\(state)/refuse').read()
+ print(words or 'ERROR: Failed to copy: the app does not allow access to its data container (get-task-allow). (com.apple.dt.CoreDeviceError error 7)', flush=True)
sys.exit(1)
print('Copied', flush=True)
elif a[:4] == ['devicectl', 'device', 'info', 'apps']:
+ if os.path.exists('\(state)/apps-locked'):
+ print('ERROR: The device is locked. (com.apple.dt.CoreDeviceError error 4)', flush=True)
+ sys.exit(1)
src = '\(state)/apps.json'
if os.path.exists(src): open(val('--json-output'), 'w').write(open(src).read())
else: json.dump({'result': {'apps': []}}, open(val('--json-output'), 'w'))
@@ -422,13 +426,107 @@ import NXModel
XCTAssertNil(outcome.failure, "the install's Retry card does not fit")
}
- /// The failure table: only a missing app is told apart, every other devicectl error is a refusal shown with its own words.
- func testTheFailureTable() {
- XCTAssertEqual(ShellInstall.dataFailure(copyError: "ERROR: The application is not installed on the device."), .appNotFound)
- XCTAssertEqual(ShellInstall.dataFailure(copyError: "ERROR: No such app: org.nxnative.shell"), .appNotFound)
- XCTAssertEqual(ShellInstall.dataFailure(copyError: "ERROR: Failed to copy: the app does not allow access to its data container (get-task-allow)."), .refused)
- XCTAssertEqual(ShellInstall.dataFailure(copyError: "ERROR: Operation not permitted (NSPOSIXErrorDomain error 1)"), .refused)
- XCTAssertEqual(ShellInstall.dataFailure(copyError: ""), .refused)
+ /// #491: the device listed the app, so a copy that fails is a refusal whatever devicectl says, even words that sound like a missing app.
+ /// Before, such words said "Install the IPA first" to a player whose app was installed, and the Finder way was not offered.
+ func testACopyIntoAListedAppThatFailsIsAlwaysARefusal() throws {
+ let f = try makeFixture()
+ let archive = try makeArchive()
+ try listApps([("org.nxnative.shell", "NX2Apple")])
+ for words in ["ERROR: Could not find the app's data container. (com.apple.dt.CoreDeviceError error 3)",
+ "ERROR: The application is not installed on the device.", "ERROR: Operation not permitted (NSPOSIXErrorDomain error 1)"] {
+ try write(state + "/refuse", words)
+ let outcome = sender(f).sendData(titleID: titleID, archive: archive)
+ XCTAssertEqual(outcome.dataFailure, .refused, words)
+ XCTAssertEqual(outcome.detail, words)
+ XCTAssertEqual(DataSend.after(outcome, notConnected: "x"), .refused(detail: words))
+ }
+ }
+
+ /// An app list the device does not give is said in plain words, with the device's name, not as devicectl's raw line.
+ func testAnUnreadableAppListIsSaidInPlainWords() throws {
+ let f = try makeFixture()
+ let archive = try makeArchive()
+ try write(state + "/apps-locked", "")
+ let outcome = sender(f).sendData(titleID: titleID, archive: archive)
+ XCTAssertFalse(outcome.ok)
+ XCTAssertEqual(outcome.dataFailure, .noAppList)
+ XCTAssertEqual(outcome.message, String(format: L10n.string("shell.sendListFailed", .en), "Z"))
+ XCTAssertTrue(outcome.detail.contains("locked"), outcome.detail)
+ XCTAssertEqual(DataSend.after(outcome, notConnected: "x"), .failed(outcome.message))
+ XCTAssertFalse(DataSend.after(outcome, notConnected: "x").offersFinder, "a locked device is not a case for Finder")
+ }
+
+ /// The mapping from the end of a send to what step 3 shows. Only a refusal and an app the device does not list offer the Finder way.
+ func testTheEndOfASendMapsToItsStateAndOnlyFailuresOfTheCopyOfferFinder() {
+ var sent = ShellInstaller.Outcome(ok: true, message: "")
+ sent.appName = "App"
+ XCTAssertEqual(DataSend.after(sent, notConnected: "off"), .sent(app: "App"))
+ let skipped = ShellInstaller.Outcome(ok: true, message: "", copySkipped: true)
+ XCTAssertEqual(DataSend.after(skipped, notConnected: "off"), .failed("off"))
+ var several = ShellInstaller.Outcome(ok: false, message: "")
+ several.apps = [InstalledApp(bundle: "org.nxnative.shell", name: "A"), InstalledApp(bundle: "org.nxnative.shell.T", name: "B")]
+ XCTAssertEqual(DataSend.after(several, notConnected: "off"), .chooseApp(several.apps))
+ var none = ShellInstaller.Outcome(ok: false, message: "")
+ none.dataFailure = .appNotFound
+ XCTAssertEqual(DataSend.after(none, notConnected: "off"), .appNotFound)
+ var refused = ShellInstaller.Outcome(ok: false, message: "")
+ refused.dataFailure = .refused; refused.detail = "ERROR: no"
+ XCTAssertEqual(DataSend.after(refused, notConnected: "off"), .refused(detail: "ERROR: no"))
+ let space = ShellInstaller.Outcome(ok: false, message: "No space")
+ XCTAssertEqual(DataSend.after(space, notConnected: "off"), .failed("No space"))
+
+ let offers: [DataSend] = [.appNotFound, .refused(detail: "")]
+ let others: [DataSend] = [.idle, .sending(done: 0, total: 1, note: ""), .sent(app: ""), .chooseApp([]), .failed("x"),
+ .copying(done: 0, total: 1), .copied(folder: "/f")]
+ XCTAssertTrue(offers.allSatisfy(\.offersFinder))
+ XCTAssertFalse(others.contains(where: \.offersFinder), "never a second button while the first way works")
+ }
+
+ /// What Finder shows selected: the game's own folder (romfs.img and its add-on content), named by its title ID. One game's own IPA
+ /// holds its data, so it has nothing to drag.
+ func testFinderShowsTheGamesFolderForTheSharedAppAndNothingForOneGame() {
+ let archive = path("out/games", titleID)
+ XCTAssertEqual(BuildStore.finderItem(archive: archive, oneGame: false), archive)
+ XCTAssertEqual((BuildStore.finderItem(archive: archive, oneGame: false)! as NSString).lastPathComponent, titleID)
+ XCTAssertNil(BuildStore.finderItem(archive: archive, oneGame: true))
+ XCTAssertNil(BuildStore.finderItem(archive: "", oneGame: false), "nothing packed yet")
+ }
+
+ /// Copy with Finder selects the folder in Finder and opens the three steps. A new send closes them again. Before a failure it does nothing.
+ func testCopyWithFinderRevealsTheFolderAndOpensTheSteps() throws {
+ let saved = savedKeys.map { ($0, UserDefaults.standard.object(forKey: $0)) }
+ defer { for (key, value) in saved { UserDefaults.standard.set(value, forKey: key) } }
+ let stores = LauncherStores(); let model = stores.build
+ var revealed: [URL] = []
+ model.revealItem = { revealed.append($0) }
+ model.archivePath = path("out/games", titleID)
+ model.copyWithFinder(oneGame: false)
+ XCTAssertTrue(revealed.isEmpty, "only after the copy to the device did not work")
+ XCTAssertFalse(model.finderShown)
+ model.send = .refused(detail: "ERROR: no")
+ model.copyWithFinder(oneGame: false)
+ XCTAssertEqual(revealed.map(\.path), [path("out/games", titleID)])
+ XCTAssertTrue(model.finderShown)
+ model.send = .sending(done: 0, total: 0, note: "")
+ XCTAssertFalse(model.finderShown, "a new send closes the steps")
+ model.send = .appNotFound
+ model.copyWithFinder(oneGame: true)
+ XCTAssertEqual(revealed.count, 1, "one game's own IPA has nothing to drag")
+ XCTAssertFalse(model.finderShown)
+ }
+
+ /// The Finder way's texts: every required language, the same number of %@ as English, and step 3 names the shell's own button.
+ func testTheFinderWayTextsFitEveryLanguage() {
+ let keys = ["shell.sendFinder", "shell.sendFinderStep1", "shell.sendFinderStep2", "shell.sendFinderStep3", "shell.sendListFailed",
+ "shell.sendRefused", "shell.sendNoApp"]
+ func placeholders(_ text: String) -> Int { text.components(separatedBy: "%@").count - 1 }
+ for key in keys {
+ for lang in Lang.all {
+ XCTAssertEqual(placeholders(L10n.string(key, lang)), placeholders(L10n.string(key, .en)), "\(key) in \(lang.code)")
+ }
+ }
+ XCTAssertEqual(placeholders(L10n.string("shell.sendFinderStep3", .en)), 2)
+ XCTAssertNotEqual(L10n.string("ios.ui.chooseGameData", .en), "ios.ui.chooseGameData", "step 3 names a button the shell has")
}
func testTheSendButtonsNeedTheIPAAndTheirPlace() throws {
@@ -578,8 +676,8 @@ import NXModel
let keys = ["shell.exportBuildStage", "shell.exportDone", "shell.exportFailed", "shell.exportPackStage", "shell.modeTitle", "shell.modeInstall",
"shell.modeExport", "shell.step1Title", "shell.step1Sub", "shell.step1Button", "shell.step1Done", "shell.showInFinder", "shell.step2Title",
"shell.step2Sub", "shell.step3Title", "shell.step3Sub", "shell.whereDevice", "shell.whereDrive", "shell.sendButton", "shell.sendStage",
- "shell.sendProgress", "shell.sendDone", "shell.sendNoApp", "shell.sendSeveral", "shell.sendRefused", "shell.sendFinderSteps",
- "shell.sendShowData", "shell.sendDetails", "shell.driveNone", "shell.driveChoose", "shell.driveCopy", "shell.driveNote", "shell.driveFat32",
+ "shell.sendProgress", "shell.sendDone", "shell.sendNoApp", "shell.sendSeveral", "shell.sendRefused", "shell.sendFinder",
+ "shell.sendFinderStep1", "shell.sendFinderStep2", "shell.sendFinderStep3", "shell.sendListFailed", "shell.sendDetails", "shell.driveNone", "shell.driveChoose", "shell.driveCopy", "shell.driveNote", "shell.driveFat32",
"shell.driveReadOnly", "shell.driveNoSpace", "shell.driveProgress", "shell.driveDone", "shell.driveFailed"]
// The five languages the launcher ships with must have every text, translated. Any other language file (it, for one) may leave a key out:
// that key then shows the English text, and nothing here asks for it.
diff --git a/frontend/l10n/de.json b/frontend/l10n/de.json
index 42b02c39..8679d44d 100644
--- a/frontend/l10n/de.json
+++ b/frontend/l10n/de.json
@@ -1115,12 +1115,15 @@
"shell.sendButton": "Spieldaten senden",
"shell.sendDetails": "Einzelheiten",
"shell.sendDone": "Die Spieldaten sind auf dem Gerät. Öffne die App auf dem iPhone zum Spielen.",
- "shell.sendFinderSteps": "Öffne dein iPhone im Finder, wähle Dateien und ziehe den Ordner auf die App.",
- "shell.sendNoApp": "Die App ist noch nicht auf diesem Gerät. Installiere zuerst die IPA und sende dann die Spieldaten.",
+ "shell.sendFinder": "Mit Finder kopieren",
+ "shell.sendFinderStep1": "Verbinde das iPhone mit einem Kabel und wähle es in der Seitenleiste des Finders aus.",
+ "shell.sendFinderStep2": "Wähle Dateien und ziehe den Ordner %@ auf die App.",
+ "shell.sendFinderStep3": "Tippe auf dem iPhone auf das Spiel, dann auf %@, und wähle den Ordner %@.",
+ "shell.sendListFailed": "Die Apps auf %@ konnten nicht gelesen werden. Lass es verbunden und entsperrt und sende noch einmal.",
+ "shell.sendNoApp": "Die App ist noch nicht auf diesem Gerät. Installiere zuerst die IPA und sende dann die Spieldaten. Ist sie schon installiert, kopiere mit dem Finder.",
"shell.sendProgress": "Sende %@, %@ von %@.",
- "shell.sendRefused": "In diese App kann der Mac nicht schreiben. Kopiere die Spieldaten stattdessen im Finder.",
+ "shell.sendRefused": "Das Gerät hat das Kopieren in die App abgelehnt. Der Finder kann die Spieldaten stattdessen kopieren.",
"shell.sendSeveral": "Dieses Gerät hat mehrere Kopien der App. Wähle eine aus.",
- "shell.sendShowData": "Spieldaten im Finder zeigen",
"shell.sendStage": "App auf dem Gerät suchen",
"shell.showInFinder": "Im Finder zeigen",
"shell.step1Button": "IPA exportieren",
diff --git a/frontend/l10n/en.json b/frontend/l10n/en.json
index 32e52638..354bb281 100644
--- a/frontend/l10n/en.json
+++ b/frontend/l10n/en.json
@@ -1241,12 +1241,15 @@
"shell.sendButton": "Send game data",
"shell.sendDetails": "Details",
"shell.sendDone": "Game data is on the device. Open the app on the iPhone to play.",
- "shell.sendFinderSteps": "Open your iPhone in Finder, choose Files, then drag the folder onto the app.",
- "shell.sendNoApp": "The app isn’t on this device yet. Install the IPA first, then send the game data.",
+ "shell.sendFinder": "Copy with Finder",
+ "shell.sendFinderStep1": "Connect the iPhone with a cable and select it in the Finder sidebar.",
+ "shell.sendFinderStep2": "Choose Files, then drag the folder %@ onto the app.",
+ "shell.sendFinderStep3": "On the iPhone, tap the game, then %@, and pick the folder %@.",
+ "shell.sendListFailed": "The apps on %@ could not be read. Keep it connected and unlocked, then send again.",
+ "shell.sendNoApp": "The app isn’t on this device yet. Install the IPA first, then send the game data. If it is installed already, copy with Finder.",
"shell.sendProgress": "Sending %@, %@ of %@.",
- "shell.sendRefused": "This app can’t be written to from the Mac. Copy the game data in Finder instead.",
+ "shell.sendRefused": "The device refused the copy into the app. Finder can copy the game data instead.",
"shell.sendSeveral": "This device has several copies of the app. Choose one.",
- "shell.sendShowData": "Show game data in Finder",
"shell.sendStage": "Look for the app on the device",
"shell.showInFinder": "Show in Finder",
"shell.step1Button": "Export IPA",
diff --git a/frontend/l10n/fr.json b/frontend/l10n/fr.json
index 7509a532..5f33806a 100644
--- a/frontend/l10n/fr.json
+++ b/frontend/l10n/fr.json
@@ -1117,12 +1117,15 @@
"shell.sendButton": "Envoyer les données",
"shell.sendDetails": "Détails",
"shell.sendDone": "Les données du jeu sont sur l’appareil. Ouvrez l’app sur l’iPhone pour jouer.",
- "shell.sendFinderSteps": "Ouvrez votre iPhone dans le Finder, choisissez Fichiers, puis glissez le dossier sur l’app.",
- "shell.sendNoApp": "L’app n’est pas encore sur cet appareil. Installez d’abord l’IPA, puis envoyez les données du jeu.",
+ "shell.sendFinder": "Copier avec le Finder",
+ "shell.sendFinderStep1": "Branchez l’iPhone avec un câble et sélectionnez-le dans la barre latérale du Finder.",
+ "shell.sendFinderStep2": "Choisissez Fichiers, puis glissez le dossier %@ sur l’app.",
+ "shell.sendFinderStep3": "Sur l’iPhone, touchez le jeu, puis %@, et choisissez le dossier %@.",
+ "shell.sendListFailed": "Impossible de lire les apps de %@. Gardez-le connecté et déverrouillé, puis envoyez à nouveau.",
+ "shell.sendNoApp": "L’app n’est pas encore sur cet appareil. Installez d’abord l’IPA, puis envoyez les données du jeu. Si elle est déjà installée, copiez avec le Finder.",
"shell.sendProgress": "Envoi de %@, %@ sur %@.",
- "shell.sendRefused": "Le Mac ne peut pas écrire dans cette app. Copiez plutôt les données du jeu dans le Finder.",
+ "shell.sendRefused": "L’appareil a refusé la copie dans l’app. Le Finder peut copier les données du jeu à la place.",
"shell.sendSeveral": "Cet appareil a plusieurs copies de l’app. Choisissez-en une.",
- "shell.sendShowData": "Afficher les données dans le Finder",
"shell.sendStage": "Chercher l’app sur l’appareil",
"shell.showInFinder": "Afficher dans le Finder",
"shell.step1Button": "Exporter l’IPA",
diff --git a/frontend/l10n/it.json b/frontend/l10n/it.json
index b8907b36..5ceb41f3 100644
--- a/frontend/l10n/it.json
+++ b/frontend/l10n/it.json
@@ -1118,12 +1118,15 @@
"shell.sendButton": "Invia i dati di gioco",
"shell.sendDetails": "Dettagli",
"shell.sendDone": "I dati di gioco sono sul dispositivo. Apri l’app sull’iPhone per giocare.",
- "shell.sendFinderSteps": "Apri il tuo iPhone nel Finder, scegli File, poi trascina la cartella sull’app.",
- "shell.sendNoApp": "L’app non è ancora su questo dispositivo. Installa prima l’IPA, poi invia i dati di gioco.",
+ "shell.sendFinder": "Copia con il Finder",
+ "shell.sendFinderStep1": "Collega l’iPhone con un cavo e selezionalo nella barra laterale del Finder.",
+ "shell.sendFinderStep2": "Scegli File, poi trascina la cartella %@ sull’app.",
+ "shell.sendFinderStep3": "Sull’iPhone tocca il gioco, poi %@, e scegli la cartella %@.",
+ "shell.sendListFailed": "Non è stato possibile leggere le app su %@. Tienilo collegato e sbloccato, poi invia di nuovo.",
+ "shell.sendNoApp": "L’app non è ancora su questo dispositivo. Installa prima l’IPA, poi invia i dati di gioco. Se è già installata, copia con il Finder.",
"shell.sendProgress": "Invio di %@, %@ di %@.",
- "shell.sendRefused": "Da questo Mac non si può scrivere in questa app. Copia invece i dati di gioco nel Finder.",
+ "shell.sendRefused": "Il dispositivo ha rifiutato la copia nell’app. Il Finder può copiare i dati di gioco al suo posto.",
"shell.sendSeveral": "Questo dispositivo ha più copie dell’app. Scegline una.",
- "shell.sendShowData": "Mostra i dati di gioco nel Finder",
"shell.sendStage": "Cerca l’app sul dispositivo",
"shell.showInFinder": "Mostra nel Finder",
"shell.step1Button": "Esporta IPA",
diff --git a/frontend/l10n/sv.json b/frontend/l10n/sv.json
index 1312a647..5aaac8ad 100644
--- a/frontend/l10n/sv.json
+++ b/frontend/l10n/sv.json
@@ -955,12 +955,15 @@
"shell.sendButton": "Skicka speldata",
"shell.sendDetails": "Detaljer",
"shell.sendDone": "Speldata finns på enheten. Öppna appen på iPhone för att spela.",
- "shell.sendFinderSteps": "Öppna din iPhone i Finder, välj Filer och dra mappen till appen.",
- "shell.sendNoApp": "Appen finns inte på den här enheten än. Installera IPA-filen först och skicka sedan speldata.",
+ "shell.sendFinder": "Kopiera med Finder",
+ "shell.sendFinderStep1": "Anslut iPhone med en kabel och markera den i Finders sidofält.",
+ "shell.sendFinderStep2": "Välj Filer och dra mappen %@ till appen.",
+ "shell.sendFinderStep3": "Tryck på spelet på iPhone, sedan på %@, och välj mappen %@.",
+ "shell.sendListFailed": "Apparna på %@ kunde inte läsas. Håll den ansluten och upplåst och skicka igen.",
+ "shell.sendNoApp": "Appen finns inte på den här enheten än. Installera IPA-filen först och skicka sedan speldata. Om den redan är installerad, kopiera med Finder.",
"shell.sendProgress": "Skickar %@, %@ av %@.",
- "shell.sendRefused": "Det går inte att skriva till den här appen från Macen. Kopiera speldata i Finder i stället.",
+ "shell.sendRefused": "Enheten nekade kopieringen till appen. Finder kan kopiera speldata i stället.",
"shell.sendSeveral": "Den här enheten har flera kopior av appen. Välj en.",
- "shell.sendShowData": "Visa speldata i Finder",
"shell.sendStage": "Leta efter appen på enheten",
"shell.showInFinder": "Visa i Finder",
"shell.step1Button": "Exportera IPA",
diff --git a/frontend/l10n/zh.json b/frontend/l10n/zh.json
index 4884f1c1..5e197874 100644
--- a/frontend/l10n/zh.json
+++ b/frontend/l10n/zh.json
@@ -1242,12 +1242,15 @@
"shell.sendButton": "发送游戏数据",
"shell.sendDetails": "详细信息",
"shell.sendDone": "游戏数据已在设备上。在 iPhone 上打开应用即可游玩。",
- "shell.sendFinderSteps": "在访达中打开你的 iPhone,选择“文件”,再把文件夹拖到应用上。",
- "shell.sendNoApp": "应用还不在这台设备上。请先安装 IPA,再发送游戏数据。",
+ "shell.sendFinder": "用访达复制",
+ "shell.sendFinderStep1": "用数据线连接 iPhone,并在访达边栏中选择它。",
+ "shell.sendFinderStep2": "选择“文件”,然后把文件夹 %@ 拖到应用上。",
+ "shell.sendFinderStep3": "在 iPhone 上轻点游戏,再轻点“%@”,然后选择文件夹 %@。",
+ "shell.sendListFailed": "无法读取 %@ 上的应用。请保持连接并解锁,然后重新发送。",
+ "shell.sendNoApp": "应用还不在这台设备上。请先安装 IPA,再发送游戏数据。如果已经安装,请用访达复制。",
"shell.sendProgress": "正在发送 %@,%@ / %@。",
- "shell.sendRefused": "无法从 Mac 写入这个应用。请改用访达复制游戏数据。",
+ "shell.sendRefused": "设备拒绝了向应用复制。可以改用访达复制游戏数据。",
"shell.sendSeveral": "这台设备上有多份该应用。请选择一份。",
- "shell.sendShowData": "在访达中显示游戏数据",
"shell.sendStage": "在设备上查找应用",
"shell.showInFinder": "在访达中显示",
"shell.step1Button": "导出 IPA",