Skip to content

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

Cheats sheet: say that cheats are turned off on iPhone and iPad

v0lumehie8a310eeeb58
diff --git a/frontend/Sources/NSPortBuilder/CheatsView.swift b/frontend/Sources/NSPortBuilder/CheatsView.swift
index 69df8421..1b8b4c33 100644
--- a/frontend/Sources/NSPortBuilder/CheatsView.swift
+++ b/frontend/Sources/NSPortBuilder/CheatsView.swift
@@ -46,6 +46,7 @@ struct CheatsView: View {
.padding(.horizontal, 30).padding(.top, 28).padding(.bottom, 16)
VStack(alignment: .leading, spacing: 14) {
buildCard
+ if game?.cheatsNeedIOSNote ?? false { iosNoteCard }
if files.isEmpty { emptyCard } else { listCard }
actions
if busy {
@@ -125,6 +126,18 @@ struct CheatsView: View {
}
}
+ /// Cheats do not run on iPhone or iPad yet: said once, calmly, with the switches left usable for a Mac build.
+ private var iosNoteCard: some View {
+ HStack(alignment: .top, spacing: 14) {
+ Image(systemName: "info.circle").font(.system(size: 16, weight: .light)).foregroundStyle(.secondary).frame(width: 26)
+ Text(m.t("cheats.iosNote")).font(.manrope(12.5)).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
+ Spacer(minLength: 0)
+ }
+ .padding(.horizontal, 18).padding(.vertical, 11)
+ .background(Color.white.opacity(0.04), in: RoundedRectangle(cornerRadius: 14))
+ .accessibilityElement(children: .combine)
+ }
+
private var emptyCard: some View {
card {
VStack(spacing: 10) {
diff --git a/frontend/Sources/NSPortBuilder/Library.swift b/frontend/Sources/NSPortBuilder/Library.swift
index 0556e597..5612cef4 100644
--- a/frontend/Sources/NSPortBuilder/Library.swift
+++ b/frontend/Sources/NSPortBuilder/Library.swift
@@ -32,6 +32,9 @@ struct LibraryGame: Codable, Identifiable, Equatable {
/// Signed and installed on a paired device (installedDevice is its UDID): Play starts it there.
var onDevice: Bool { !installedDevice.isEmpty && FileManager.default.fileExists(atPath: iosAppPath + "/Info.plist") }
+ /// Cheats are turned off when an iPhone or iPad game starts (iOS does not allow changing the game's code, seedds/nxnative#724),
+ /// so the Cheats sheet says so for a game that has an iOS build. The switches stay usable: the same game may have a Mac build.
+ var cheatsNeedIOSNote: Bool { hasIOSBuild || onDevice }
var hasIOSBuild: Bool { hasIPA || hasIOSApp }
var hasIPA: Bool { !ipaPath.isEmpty && FileManager.default.fileExists(atPath: ipaPath) }
var hasIOSApp: Bool { !iosAppPath.isEmpty && FileManager.default.fileExists(atPath: iosAppPath + "/Info.plist") }
diff --git a/frontend/Sources/NSPortBuilder/Localization.swift b/frontend/Sources/NSPortBuilder/Localization.swift
index cc2957a1..1973d96d 100644
--- a/frontend/Sources/NSPortBuilder/Localization.swift
+++ b/frontend/Sources/NSPortBuilder/Localization.swift
@@ -326,6 +326,7 @@ enum L10n {
"cheats.dropHint": ("松开以导入金手指", "Drop to import cheats"),
"cheats.note": ("开关会立即保存,游戏下次启动时生效。", "Switches are saved at once and apply the next time the game starts."),
"cheats.noteDevice": ("更改后请再次复制到 %@。", "Copy to %@ again after a change."),
+ "cheats.iosNote": ("金手指在 Mac 版应用中可用。在 iPhone 和 iPad 上,游戏启动时它们会被关闭,因为 iOS 不允许修改游戏的代码(seedds/nxnative#724)。", "Cheats work in the Mac app. On iPhone and iPad they are turned off when the game starts, because iOS does not allow changing the game's code (seedds/nxnative#724)."),
"pad.manage": ("管理", "Manage"),
"dev.signStage": ("\u{4e3a} %@ \u{7b7e}\u{540d}", "Sign for %@"),
"dev.installStage": ("\u{5b89}\u{88c5}\u{5230} %@", "Install on %@"),
@@ -1225,6 +1226,7 @@ enum L10n {
"cheats.dropHint": "Släpp för att importera fusk",
"cheats.note": "Reglagen sparas direkt och gäller nästa gång spelet startas.",
"cheats.noteDevice": "Kopiera till %@ igen efter en ändring.",
+ "cheats.iosNote": "Fusk fungerar i Mac-appen. På iPhone och iPad stängs det av när spelet startar, eftersom iOS inte tillåter att spelets kod ändras (seedds/nxnative#724).",
"pad.manage": "Hantera",
"dev.signStage": "Signerar för %@",
"dev.installStage": "Installerar på %@",
diff --git a/frontend/Tests/NSPortBuilderTests/CheatFilesTests.swift b/frontend/Tests/NSPortBuilderTests/CheatFilesTests.swift
index 07f38804..6bf9b8c3 100644
--- a/frontend/Tests/NSPortBuilderTests/CheatFilesTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/CheatFilesTests.swift
@@ -408,3 +408,34 @@ final class CheatFilesTests: XCTestCase {
try shot("cheats-empty", CheatsView(m: model, library: library, gameID: id, support: support))
}
}
+
+/// Issue #252: cheats are turned off when an iPhone or iPad game starts, so the Cheats sheet carries a note for a game with an iOS build.
+final class CheatsIOSNoteTests: XCTestCase {
+ func testNoteShowsOnlyWithAnIOSBuild() throws {
+ let dir = FileManager.default.temporaryDirectory.appendingPathComponent("nxnative-iosnote-" + UUID().uuidString)
+ try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: true)
+ defer { try? FileManager.default.removeItem(at: dir) }
+ let ipa = dir.appendingPathComponent("Game.ipa")
+ try Data("x".utf8).write(to: ipa)
+ let ios = dir.appendingPathComponent("Game.app")
+ try FileManager.default.createDirectory(at: ios, withIntermediateDirectories: true)
+ try Data("x".utf8).write(to: ios.appendingPathComponent("Info.plist"))
+
+ var game = LibraryGame(titleID: "0100F2C0115B6000", name: "Game", appPath: "/gone/Game.app")
+ XCTAssertFalse(game.cheatsNeedIOSNote, "a Mac-only game has no note")
+ game.ipaPath = ipa.path
+ XCTAssertTrue(game.cheatsNeedIOSNote, "a built IPA gets it")
+ game.ipaPath = dir.appendingPathComponent("gone.ipa").path
+ XCTAssertFalse(game.cheatsNeedIOSNote, "an IPA that is gone does not")
+ game.iosAppPath = ios.path
+ game.installedDevice = "device"
+ XCTAssertTrue(game.cheatsNeedIOSNote, "a game installed on a device gets it")
+ }
+
+ func testNoteIsTranslatedWithoutSemicolons() {
+ for lang in [Lang.en, .zh, .sv] {
+ let text = L10n.string("cheats.iosNote", lang)
+ XCTAssertFalse(text.isEmpty); XCTAssertFalse(text.contains(";")); XCTAssertTrue(text.contains("#724"))
+ }
+ }
+}