Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Cheats sheet: say that cheats are turned off on iPhone and iPad
The engine cannot change the game's code on iOS (seedds/nxnative#724), so every
entry is turned off at start. The sheet now says so for a game with an iOS build
and leaves the switches usable for a Mac build. Refs #252.
  • Loading branch information
v0lumehi committed Oct 30, 2026
commit e8a310eeeb58dbfae2162ab9e2e4d81e3ae46fbd
13 changes: 13 additions & 0 deletions frontend/Sources/NSPortBuilder/CheatsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions frontend/Sources/NSPortBuilder/Library.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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") }
Expand Down
2 changes: 2 additions & 0 deletions frontend/Sources/NSPortBuilder/Localization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 %@"),
Expand Down Expand Up @@ -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å %@",
Expand Down
31 changes: 31 additions & 0 deletions frontend/Tests/NSPortBuilderTests/CheatFilesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
}
}
Loading