Skip to content

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

Update sheet: render release notes as Markdown with links

v0lumehi2553f79fe1bf
diff --git a/frontend/Sources/NSPortBuilder/ReleaseNotes.swift b/frontend/Sources/NSPortBuilder/ReleaseNotes.swift
new file mode 100644
index 00000000..60b0513f
--- /dev/null
+++ b/frontend/Sources/NSPortBuilder/ReleaseNotes.swift
@@ -0,0 +1,171 @@
+import Foundation
+
+/// The update sheet's release notes: which lines belong to the interface language, how they split into
+/// blocks (headings, bullets, paragraphs) and how a line's inline Markdown becomes an AttributedString
+/// with links. All pure, so the tests run it on real release bodies. UpdateSheet only styles the result.
+///
+/// The release body follows docs/RELEASE-NOTES-GUIDE.md. Two shapes are in the wild:
+///
+/// * **Current**: English written out in full, `---`, then Chinese in full. The `---` is the split.
+/// * **Older releases (0.4.7 and before)**: `**中文** …` and `**English** …` paragraphs with bullet
+/// lists interleaved one line each. Those are split on the markers.
+///
+/// A body with neither is shown whole: splitting it by guesswork is how the first version gave an
+/// English reader the Chinese paragraph (that line contains both scripts).
+enum ReleaseNotes {
+ enum Block: Equatable {
+ case heading(AttributedString)
+ case bullet(AttributedString)
+ case paragraph(AttributedString)
+ }
+
+ /// The repository bare `#123` references point into.
+ static let repository = "LNPANDY/NX2Apple"
+
+ // ---- Language split ----
+
+ /// The body's Markdown lines for one language, still carrying their Markdown (`##`, `- `, `**`).
+ static func lines(_ notes: String, for lang: Lang) -> [String] {
+ // Shape 1: two halves around a `---` line.
+ let halves = notes.components(separatedBy: "\n---\n")
+ if halves.count == 2 {
+ let first = clean(halves[0]), second = clean(halves[1])
+ // Pick by which half is which, not by order alone, so a body written the other way round still reads correctly.
+ let firstIsEnglish = !containsHan(first.joined())
+ let english = firstIsEnglish ? first : second
+ let chinese = firstIsEnglish ? second : first
+ if !english.isEmpty && !chinese.isEmpty { return lang == .zh ? chinese : english }
+ }
+
+ // Shape 2: `**中文**` / `**English**` markers.
+ var zh: [String] = [], en: [String] = []
+ var marked = 0
+ for raw in notes.split(separator: "\n", omittingEmptySubsequences: false) {
+ let s = raw.trimmingCharacters(in: .whitespaces)
+ if s.isEmpty || s.hasPrefix("---") { continue }
+ if s.hasPrefix("#") { zh.append(s); en.append(s); continue }
+ if let r = s.range(of: "**中文**") {
+ marked += 1
+ zh.append(s[r.upperBound...].trimmingCharacters(in: .whitespaces))
+ } else if let r = s.range(of: "**English**") {
+ marked += 1
+ en.append(s[r.upperBound...].trimmingCharacters(in: .whitespaces))
+ } else if containsHan(s) { zh.append(s) } else { en.append(s) }
+ }
+ if marked > 0, !zh.isEmpty, !en.isEmpty { return lang == .zh ? zh : en }
+
+ // Neither shape: show it as it is.
+ return clean(notes)
+ }
+
+ /// The Markdown for one language as a single string, ready for `blocks(from:)`.
+ static func markdown(_ notes: String, for lang: Lang) -> String { lines(notes, for: lang).joined(separator: "\n") }
+
+ /// One half of a body as lines: blanks and rules dropped, the old language markers removed.
+ private static func clean(_ half: String) -> [String] {
+ half.split(separator: "\n", omittingEmptySubsequences: false).compactMap { raw in
+ let s = raw.trimmingCharacters(in: .whitespaces)
+ .replacingOccurrences(of: "**中文**", with: "")
+ .replacingOccurrences(of: "**English**", with: "")
+ .trimmingCharacters(in: .whitespaces)
+ return s.isEmpty || s.hasPrefix("---") ? nil : s
+ }
+ }
+
+ private static func containsHan(_ s: String) -> Bool {
+ s.unicodeScalars.contains { (0x4e00...0x9fff).contains($0.value) }
+ }
+
+ // ---- Blocks ----
+
+ /// Markdown lines as blocks. A line is a heading (`#`..`######`), a bullet (`- `, `* `, `+ `) or a
+ /// paragraph. A line indented under a bullet continues that bullet. Blank lines and `---` are dropped.
+ static func blocks(from markdown: String) -> [Block] {
+ var out: [Block] = []
+ var pendingBullet: String?
+ func flush() {
+ if let b = pendingBullet { out.append(.bullet(inline(b))); pendingBullet = nil }
+ }
+ for raw in markdown.split(separator: "\n", omittingEmptySubsequences: false) {
+ let line = String(raw)
+ let s = line.trimmingCharacters(in: .whitespaces)
+ if s.isEmpty || isRule(s) { flush(); continue }
+ if let text = headingText(s) {
+ flush()
+ if !text.isEmpty { out.append(.heading(inline(text))) }
+ } else if let text = bulletText(s) {
+ flush()
+ pendingBullet = text
+ } else if pendingBullet != nil, line.first == " " || line.first == "\t" {
+ pendingBullet! += " " + s
+ } else {
+ flush()
+ out.append(.paragraph(inline(s)))
+ }
+ }
+ flush()
+ return out
+ }
+
+ private static func isRule(_ s: String) -> Bool {
+ s.count >= 3 && (s.allSatisfy { $0 == "-" } || s.allSatisfy { $0 == "*" } || s.allSatisfy { $0 == "_" })
+ }
+
+ private static func headingText(_ s: String) -> String? {
+ let hashes = s.prefix { $0 == "#" }.count
+ guard (1...6).contains(hashes) else { return nil }
+ let rest = s.dropFirst(hashes)
+ guard rest.isEmpty || rest.first == " " else { return nil } // `#123` is a reference, not a heading
+ return rest.trimmingCharacters(in: .whitespaces)
+ }
+
+ private static func bulletText(_ s: String) -> String? {
+ guard let first = s.first, "-*+".contains(first), s.dropFirst().first == " " else { return nil }
+ return s.dropFirst(2).trimmingCharacters(in: .whitespaces)
+ }
+
+ // ---- Inline ----
+
+ /// A line's inline Markdown (bold, italic, code, links) with GitHub references and bare URLs made links.
+ static func inline(_ text: String) -> AttributedString {
+ let options = AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnly, failurePolicy: .returnPartiallyParsedIfPossible)
+ var out = (try? AttributedString(markdown: text, options: options)) ?? AttributedString(text)
+ autolink(&out)
+ return out
+ }
+
+ /// A bare URL, `owner/repo#123`, `#123` or `@login`, leftmost first. Groups: 1 URL, 2 repo, 3 repo's
+ /// number, 4 number, 5 login.
+ private static let pattern = try! NSRegularExpression(pattern: """
+ (https?://[^\\s<>\\]]+)\
+ |(?<![\\w/.@-])([A-Za-z0-9][A-Za-z0-9-]*/[A-Za-z0-9._-]*[A-Za-z0-9_])#(\\d+)(?![\\w])\
+ |(?<![\\w#&])#(\\d+)(?![\\w])\
+ |(?<![\\w@./+-])@([A-Za-z0-9](?:[A-Za-z0-9]|-(?=[A-Za-z0-9])){0,38})(?![\\w@-])
+ """)
+
+ private static func autolink(_ s: inout AttributedString) {
+ let plain = String(s.characters)
+ let whole = NSRange(plain.startIndex..., in: plain)
+ for m in pattern.matches(in: plain, range: whole) {
+ func group(_ i: Int) -> String? { Range(m.range(at: i), in: plain).map { String(plain[$0]) } }
+ var range = Range(m.range, in: plain)!
+ let target: String
+ if var url = group(1) {
+ while let last = url.last, ".,;:!?)'\"".contains(last) { url.removeLast() }
+ // A `)` that closes a parenthesis opened inside the URL belongs to it, but release notes rarely need that.
+ range = range.lowerBound..<plain.index(range.lowerBound, offsetBy: url.count)
+ target = url
+ } else if let repo = group(2), let n = group(3) { target = "https://github.com/\(repo)/issues/\(n)"
+ } else if let n = group(4) { target = "https://github.com/\(repository)/issues/\(n)"
+ } else if let login = group(5) { target = "https://github.com/\(login)"
+ } else { continue }
+ guard let url = URL(string: target),
+ let lo = AttributedString.Index(range.lowerBound, within: s),
+ let hi = AttributedString.Index(range.upperBound, within: s) else { continue }
+ let span = lo..<hi
+ // Not inside code or an existing link.
+ if s[span].runs.contains(where: { $0.link != nil || $0.inlinePresentationIntent?.contains(.code) == true }) { continue }
+ s[span].link = url
+ }
+ }
+}
diff --git a/frontend/Sources/NSPortBuilder/UpdateSheet.swift b/frontend/Sources/NSPortBuilder/UpdateSheet.swift
index e5716e47..92a26cb5 100644
--- a/frontend/Sources/NSPortBuilder/UpdateSheet.swift
+++ b/frontend/Sources/NSPortBuilder/UpdateSheet.swift
@@ -8,6 +8,7 @@ import SwiftUI
/// The notes come from the release body, which this project writes in both languages (see
/// docs/RELEASE-NOTES-GUIDE.md). The sheet does not try to translate them; it shows the lines that
/// match the interface language and falls back to the whole body when it cannot tell them apart.
+/// ReleaseNotes turns them into blocks with links, and this file only styles those.
struct UpdateSheet: View {
@ObservedObject var m: BuildModel
@Environment(\.dismiss) private var dismiss
@@ -25,13 +26,11 @@ struct UpdateSheet: View {
.padding(.horizontal, 28).padding(.top, 26).padding(.bottom, 18)
ScrollView {
- VStack(alignment: .leading, spacing: 10) {
+ VStack(alignment: .leading, spacing: 6) {
if let notes = update?.notes, !notes.isEmpty {
- ForEach(Array(Self.lines(notes, for: m.lang).enumerated()), id: \.offset) { _, line in
- Text(line)
- .font(.manrope(13))
- .fixedSize(horizontal: false, vertical: true)
- .frame(maxWidth: .infinity, alignment: .leading)
+ let blocks = ReleaseNotes.blocks(from: ReleaseNotes.markdown(notes, for: m.lang))
+ ForEach(Array(blocks.enumerated()), id: \.offset) { index, block in
+ blockView(block, first: index == 0)
}
} else {
Text(m.t("update.noNotes")).font(.manrope(13)).foregroundStyle(.secondary)
@@ -79,74 +78,49 @@ struct UpdateSheet: View {
.tint(LauncherPalette.cream)
}
- /// The release body's lines for one language.
- ///
- /// Two shapes are in the wild, both described in docs/RELEASE-NOTES-GUIDE.md:
- ///
- /// * **Current**: English written out in full, `---`, then Chinese in full. The `---` is the
- /// split, so the two halves are read straight through and neither reader sees the other's text.
- /// * **Older releases (0.4.7 and before)**: `**中文** …` and `**English** …` paragraphs with the
- /// bullet lists interleaved one line each. Those are split on the markers.
- ///
- /// A body with neither is shown whole — splitting it by guesswork is how the first version gave
- /// an English reader the Chinese paragraph (that line contains both scripts).
- static func lines(_ notes: String, for lang: Lang) -> [String] {
- // Shape 1: two halves around a `---` line.
- let halves = notes.components(separatedBy: "\n---\n")
- if halves.count == 2 {
- let first = clean(halves[0]), second = clean(halves[1])
- // The English half first, as the guide requires; pick by which half is which, not by order
- // alone, so a body written the other way round still reads correctly.
- let firstIsEnglish = !containsHan(first.joined())
- let english = firstIsEnglish ? first : second
- let chinese = firstIsEnglish ? second : first
- if !english.isEmpty && !chinese.isEmpty { return lang == .zh ? chinese : english }
- }
-
- // Shape 2: `**中文**` / `**English**` markers.
- var zh: [String] = [], en: [String] = []
- var marked = 0
- for raw in notes.split(separator: "\n", omittingEmptySubsequences: false) {
- var s = raw.trimmingCharacters(in: .whitespaces)
- if s.isEmpty || s.hasPrefix("---") { continue }
- if s.hasPrefix("#") {
- while s.hasPrefix("#") { s.removeFirst() }
- s = s.trimmingCharacters(in: .whitespaces)
- if !s.isEmpty { zh.append(s); en.append(s) }
- continue
- }
- if let r = s.range(of: "**中文**") {
- marked += 1
- zh.append(s[r.upperBound...].replacingOccurrences(of: "**", with: "").trimmingCharacters(in: .whitespaces))
- } else if let r = s.range(of: "**English**") {
- marked += 1
- en.append(s[r.upperBound...].replacingOccurrences(of: "**", with: "").trimmingCharacters(in: .whitespaces))
- } else {
- s = s.replacingOccurrences(of: "**", with: "")
- if containsHan(s) { zh.append(s) } else { en.append(s) }
+ @ViewBuilder private func blockView(_ block: ReleaseNotes.Block, first: Bool) -> some View {
+ switch block {
+ case .heading(let text):
+ Text(Self.styled(text, size: 12.5, weight: .bold))
+ .foregroundStyle(.secondary)
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.top, first ? 0 : 14)
+ case .bullet(let text):
+ // A hanging indent: the bullet is its own column, so wrapped lines align with the text.
+ HStack(alignment: .firstTextBaseline, spacing: 8) {
+ Text("\u{2022}").font(.manrope(13)).foregroundStyle(.secondary).frame(width: 10, alignment: .center)
+ Text(Self.styled(text, size: 13))
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
}
+ .padding(.leading, 2)
+ case .paragraph(let text):
+ Text(Self.styled(text, size: 13))
+ .fixedSize(horizontal: false, vertical: true)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.vertical, 3)
}
- if marked > 0, !zh.isEmpty, !en.isEmpty { return lang == .zh ? zh : en }
-
- // Neither shape: show it as it is.
- return clean(notes)
}
- /// One half of a body as display lines: heading marks and bold marks stripped, blanks dropped.
- private static func clean(_ half: String) -> [String] {
- half.split(separator: "\n", omittingEmptySubsequences: false).compactMap { raw in
- var s = raw.trimmingCharacters(in: .whitespaces)
- if s.isEmpty || s.hasPrefix("---") { return nil }
- while s.hasPrefix("#") { s.removeFirst() }
- s = s.replacingOccurrences(of: "**中文**", with: "")
- .replacingOccurrences(of: "**English**", with: "")
- .replacingOccurrences(of: "**", with: "")
- .trimmingCharacters(in: .whitespaces)
- return s.isEmpty ? nil : s
+ /// The launcher's look on a parsed line: Manrope, bold and italic runs, code in the monospaced face on a
+ /// faint background, links in the accent colour. Links open in the default browser (SwiftUI's openURL).
+ static func styled(_ text: AttributedString, size: CGFloat, weight: Font.Weight = .regular) -> AttributedString {
+ var out = text
+ for run in text.runs {
+ let intent = run.inlinePresentationIntent ?? []
+ var font = Font.manrope(size, intent.contains(.stronglyEmphasized) ? .bold : weight)
+ if intent.contains(.emphasized) { font = font.italic() }
+ if intent.contains(.code) {
+ font = .mono(size - 1, intent.contains(.stronglyEmphasized) ? .bold : .regular)
+ out[run.range].backgroundColor = Color.white.opacity(0.10)
+ }
+ out[run.range].font = font
+ if run.link != nil {
+ out[run.range].foregroundColor = LauncherPalette.cream
+ out[run.range].underlineStyle = .single
+ }
}
- }
-
- private static func containsHan(_ s: String) -> Bool {
- s.unicodeScalars.contains { (0x4e00...0x9fff).contains($0.value) }
+ return out
}
}
diff --git a/frontend/Tests/Fixtures/release_v0.7.0.md b/frontend/Tests/Fixtures/release_v0.7.0.md
new file mode 100644
index 00000000..dbe5def0
--- /dev/null
+++ b/frontend/Tests/Fixtures/release_v0.7.0.md
@@ -0,0 +1,98 @@
+## What this release does
+
+**The launcher becomes the whole computer a player needs — and then some.** A first-run wizard walks a new player through Xcode, keys and games with the tools already inside the app; the library goes full-screen controller-first like a Switch home menu; saves follow a game between Mac and iPhone through one iCloud Drive folder; a deleted app reinstalls in seconds; and a free Apple ID's 7-day signature renews in place. The repository's upstream sync is a patch queue now, so fixes land faster and nothing is lost.
+
+## New
+
+- **Guided first-run setup** (#119, #120): welcome → platform (Mac, iPhone or both) → Xcode → keys → games. The Xcode step opens the App Store and polls for the install, runs one administrator prompt to switch the toolchain and finish the first launch, then downloads the Metal Toolchain and (iPhone/both) the iOS platform with progress. Everything else installs in the background, with a real "Installing…" state per tool. Setup resumes where it left off; a player whose setup is already complete never sees it; Settings has "Run setup again".
+- **The build tools and a Python ship inside the app** (#154): zstd, glslangValidator, spirv-cross, xcodegen and CPython 3.13 with every package the build needs — all from pinned, checksummed sources, license files included. Nobody installs Homebrew or Python; the floor stays at macOS 13.
+- **Reinstall without rebuilding** (#155): the install card gains Reinstall — `devicectl` puts the signed app from the last build back on the device in seconds, with game data and saves intact. **Save IPA…** exports it as a standard IPA for a sideloader or another Mac. The Manage menu carries both, and the app knows whether each game is actually installed on the connected device.
+- **Signature expiry and renewal** (#156): the game card shows the days left on a free Apple ID's 7-day provisioning (orange at two days or fewer). Renew re-signs in place — Xcode reuses every compiled product, only the signature changes — then installs over itself. Game data is preserved.
+- **Console mode** (#169): with a controller connected, press Select (DualShock Share, DualSense Create, Xbox View, Nintendo Minus) or View → Console Mode: the library goes full screen, controller-first — covers, launch options through the saved choices, battery chips, Controllers list, glyphs that follow the last input. D-pad and stick move, A activates, B backs out, + and X open game options, Y opens Controllers. Also reachable at Option-Command-K.
+- **Cloud saves** (#185): a game's Mac app and iPhone app play on from one save through an iCloud Drive folder the player picks in each launcher. Whole-file sync with SHA-256 checks, per-date backups of every replaced save, both directions verified with Tears of the Kingdom on real devices.
+- **Build failures become rows that name the reason and the next step** (#166/#205): the Intel-Python, shader-translator, iOS-SDK and CommandLineTools stops each get their explanation plus a Build anyway button where it makes sense.
+- **Swedish localization** (#168): the whole interface, selected from the device language.
+- **A player's README**: install, play, games, limitations — 1,900 words instead of 8,000. Building from source moved to BUILDING.md, the games gallery to GAMES.md, the update history to CHANGELOG.md.
+- **Issue triage in report mode** (#143): the Copilot CLI labels new issues, asks for missing form answers, and matches `[RED]` log lines against the symptom index — labels apply, the comment lands in the job summary for a human to post.
+- **Windows**: the dependency panel guides the two Apple downloads (iPhoneOS SDK, Metal Developer Tools) with the exact steps, and a deep-dependency crash in the link probe is fixed (#192/#196).
+
+## Fixes
+
+- **Xcode installed but never opened**: the dependency row said "no iOS SDK" and offered a download that could not run (xcode-select still on CommandLineTools). It is its own state now — Xcode installed, not selected — with a one-click Fix.
+- **A failed dependency install names the reason**: the row shows the tool's own error line, and for known causes the exact command (Homebrew's folder owned by another user → `sudo chown -R $(whoami) /opt/homebrew`; Homebrew missing → brew.sh; the Xcode license → `sudo xcodebuild -license accept`; network → check proxy).
+- **A bundle-ID check no longer crashes on another user's project**: the Xcode workspace records absolute paths, and a new macOS user inherits the first user's entries — unreadable projects are pruned automatically.
+- **The diagnostics block no longer prints `(null)`** for the second version in a dependency description, and the updater's dependency check finds the Pythons `uv` installs.
+- **The updater's strings survive CI**: the shared localization table is the single source for both front ends.
+
+## Known issues
+
+- **Mods have not been played with a real mod yet**: the layouts and the environment string are verified; the actual overlay is not.
+- **Route C M1** (game modules as an opt-in framework) is in review and not part of this release.
+- **Windows**: the full build pipeline is not verified on real hardware; the front end is. The Actions artifact `NS-Port-Builder-qt-windows-x64` has the current front end.
+
+## Install
+
+- **macOS**: download `NX2Apple-macOS-arm64.zip`, unzip, right-click → Open on first launch. In-app updates work from 0.4.9 on under the NX2Apple name.
+- **Windows**: not provided on this page; the Actions artifact has the Qt front end.
+
+## Credits
+
+- **v0lumehi**: onboarding, bundled tools, the patch-queue sync model, console mode, build-failure hints, diagnostics, upstream-first docs, issue triage — twenty reviewed pull requests.
+- **dreamw0rk**: cloud saves, verified with Tears of the Kingdom on both platforms.
+- **yeager**: Swedish localization.
+- **pyxl-dev**: Luigi's Mansion 3 depth_mode fix.
+- **subyoung**: frame-time recording, return-after-play.
+- **a834354487 / MilesWanli**: the Pythons `uv` installs finding.
+- **lex2ok**: the Resume layer for the shader/Xcode build steps.
+- **tmrsm**: Windows IPA build handoffs.
+
+---
+
+## 这一版做了什么
+
+**启动器成为玩家需要的整台电脑——还不止。** 首次运行向导带新玩家走完 Xcode、密钥和游戏,工具已内置在 App 里;游戏库变全屏手柄操作,像 Switch 主菜单;存档通过一个 iCloud Drive 文件夹在 Mac 和 iPhone 之间跟随游戏;删掉的 App 几秒重装;免费 Apple ID 的 7 天签名原地续签。仓库的上游同步现在是补丁队列:修复落地更快,什么都不丢。
+
+## 新增
+
+- **引导式首次启动**(#119、#120):欢迎 → 平台(Mac、iPhone 或都要)→ Xcode → 密钥 → 游戏。Xcode 步骤打开 App Store 并轮询安装完成,跑一次管理员密码切换工具链并完成首次启动,然后带进度下载 Metal 工具链和(iPhone/都要)iOS 平台。其余工具后台依次安装,每个工具有真实的"正在安装…"状态。设置中断后接着来;已配置好的玩家不会看到;设置里有"重新运行设置"。
+- **构建工具和 Python 内置在 App 里**(#154):zstd、glslangValidator、spirv-cross、xcodegen 和 CPython 3.13(含构建需要的全部包)——全部来自 sha256 锁定的源码,附许可文件。没人需要装 Homebrew 或 Python;最低系统保持 macOS 13。
+- **不重构建就能重装**(#155):安装卡片多了"重装"——`devicectl` 把上次构建的已签名 App 秒回设备,游戏数据和存档完好。**保存 IPA…** 导出为标准 IPA 给侧载器或另一台 Mac。管理菜单也有,且 App 知道每个游戏是否真的装在连接的设备上。
+- **签名到期与续签**(#156):游戏卡片显示免费 Apple ID 的 7 天签名剩余天数(剩两天变橙)。续签原地重签——Xcode 复用全部编译产物,只换签名——然后装回手机。游戏数据保留。
+- **主机模式**(#169):手柄连接后按 Select(DualShock Share、DualSense Create、Xbox View、Nintendo Minus)或视图 → 主机模式:游戏库变全屏、手柄优先——封面、启动选项走保存的选择、电量徽章、手柄列表、跟随最后输入的按键图形。十字键和摇杆移动,A 启动,B 返回,+ 和 X 打开游戏选项,Y 打开手柄列表。也可用 Option-Command-K。
+- **云存档**(#185):游戏的 Mac 版和 iPhone 版通过玩家在各自启动器里选的 iCloud Drive 文件夹接力同一个存档。整文件同步 + SHA-256 校验,每次替换的存档按日期备份,两个方向都在真机用王国之泪验证过。
+- **构建失败变成行提示**(#166/#205):Intel-Python、着色器翻译器、iOS-SDK、CommandLineTools 四种停顿各自有解释,合理的场景给"仍然构建"按钮。
+- **瑞典语本地化**(#168):整个界面,按设备语言选择。
+- **玩家版 README**:安装、玩、游戏、限制——1900 词而不是 8000。源码构建移到 BUILDING.md,游戏画廊移到 GAMES.md,更新历史移到 CHANGELOG.md。
+- **Issue triage 报告模式**(#143):Copilot CLI 给新 issue 打标签、追问缺失的表单项、把 `[RED]` 日志行对照症状索引——标签生效,评论落在 job summary 由人来发。
+- **Windows**:依赖面板引导两个 Apple 下载(iPhoneOS SDK、Metal Developer Tools)的确切步骤;修复链接探针里的深度依赖崩溃(#192/#196)。
+
+## 修复
+
+- **Xcode 装了但没打开过**:依赖行说"缺 iOS SDK"并给了跑不了的下载按钮(xcode-select 还指着 CommandLineTools)。现在这是独立状态——Xcode 已安装但未选中——带一键"修复"。
+- **依赖安装失败说出原因**:行内显示工具自己的错误行,已知原因给确切命令(Homebrew 目录属主不对 → `sudo chown -R $(whoami) /opt/homebrew`;没装 Homebrew → brew.sh;Xcode 许可 → `sudo xcodebuild -license accept`;网络 → 检查代理)。
+- **bundle-ID 检查不再崩在别的用户的项目上**:Xcode workspace 记录绝对路径,新 macOS 用户继承第一个用户的条目——读不了的项目自动清理。
+- **诊断块不再打印 `(null)`**:依赖描述里的第二个版本号;更新器的依赖检查找到了 `uv` 安装的 Python。
+- **更新器的字符串在 CI 中不再丢失**:共享本地化表是两个前端的唯一来源。
+
+## 已知问题
+
+- **Mods 还没有用真正的 mod 实测过**:布局和环境变量已验证,实际的叠加加载没有。
+- **路线 C M1**(游戏模块作为可选的 framework)在评审中,不在这个版本里。
+- **Windows**:完整构建流水线未在真机验证;前端已验证。Actions 产物里有当前前端。
+
+## 安装
+
+- **macOS**:下载 `NX2Apple-macOS-arm64.zip`,解压后右键 → 打开(首次)。0.4.9 起 App 内更新在 NX2Apple 名下正常工作。
+- **Windows**:本页不提供;Actions 产物里有 Qt 前端。
+
+## 致谢
+
+- **v0lumehi**:引导流程、内置工具、补丁队列同步模型、主机模式、构建失败提示、诊断、上游优先文档、issue triage——二十个经过评审的 PR。
+- **dreamw0rk**:云存档,双平台用王国之泪验证。
+- **yeager**:瑞典语本地化。
+- **pyxl-dev**:Luigi's Mansion 3 depth_mode 修复。
+- **subyoung**:帧时间记录、游戏退出后回前台。
+- **a834354487 / MilesWanli**:`uv` 安装的 Python 的检测。
+- **lex2ok**:shader/Xcode 构建步骤的 Resume 层。
+- **tmrsm**:Windows IPA 构建交接。
+
diff --git a/frontend/Tests/NSPortBuilderTests/ReleaseNotesTests.swift b/frontend/Tests/NSPortBuilderTests/ReleaseNotesTests.swift
new file mode 100644
index 00000000..c9c4a4ec
--- /dev/null
+++ b/frontend/Tests/NSPortBuilderTests/ReleaseNotesTests.swift
@@ -0,0 +1,158 @@
+import AppKit
+import SwiftUI
+import XCTest
+@testable import NSPortBuilder
+
+/// The update sheet's Markdown: blocks and auto-links, on v0.7.0's real body
+/// (Tests/Fixtures/release_v0.7.0.md, copied from `gh release view v0.7.0`).
+final class ReleaseNotesTests: XCTestCase {
+ static let root = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent()
+ .deletingLastPathComponent().deletingLastPathComponent()
+
+ static func body() throws -> String {
+ try String(contentsOf: root.appendingPathComponent("frontend/Tests/Fixtures/release_v0.7.0.md"), encoding: .utf8)
+ }
+
+ private func links(_ s: AttributedString) -> [(String, String)] {
+ s.runs.compactMap { r in r.link.map { (String(s[r.range].characters), $0.absoluteString) } }
+ }
+ private func text(_ b: ReleaseNotes.Block) -> AttributedString {
+ switch b { case .heading(let t), .bullet(let t), .paragraph(let t): return t }
+ }
+ private func kind(_ b: ReleaseNotes.Block) -> String {
+ switch b { case .heading: return "heading"; case .bullet: return "bullet"; case .paragraph: return "paragraph" }
+ }
+
+ // ---- Auto-links ----
+
+ func testBareIssueNumberLinksToTheIssue() {
+ XCTAssertEqual(links(ReleaseNotes.inline("see #155 now")).map { [$0.0, $0.1] },
+ [["#155", "https://github.com/LNPANDY/NX2Apple/issues/155"]])
+ }
+
+ func testRepositoryQualifiedReference() {
+ XCTAssertEqual(links(ReleaseNotes.inline("forwarded seedds/nxnative#493.")).map { [$0.0, $0.1] },
+ [["seedds/nxnative#493", "https://github.com/seedds/nxnative/issues/493"]])
+ }
+
+ func testASlashPairIsTwoLinks() {
+ XCTAssertEqual(links(ReleaseNotes.inline("(#166/#205)")).map { [$0.0, $0.1] },
+ [["#166", "https://github.com/LNPANDY/NX2Apple/issues/166"],
+ ["#205", "https://github.com/LNPANDY/NX2Apple/issues/205"]])
+ }
+
+ func testMentionLinksToTheProfile() {
+ XCTAssertEqual(links(ReleaseNotes.inline("thanks @dreamw0rk, and @a-b!")).map { [$0.0, $0.1] },
+ [["@dreamw0rk", "https://github.com/dreamw0rk"], ["@a-b", "https://github.com/a-b"]])
+ }
+
+ func testNoMentionInAnEmailOrCode() {
+ let l = links(ReleaseNotes.inline("mail [email protected] or `@user` or user@host"))
+ // The Markdown parser itself links the address as mailto:, which is fine. No profile link.
+ XCTAssertFalse(l.contains { $0.1.contains("github.com") }, "\(l)")
+ }
+
+ func testNoLinksInCodeOrExistingLinksOrCSharp() {
+ XCTAssertTrue(links(ReleaseNotes.inline("`#155` and `seedds/nxnative#1`")).isEmpty)
+ XCTAssertTrue(links(ReleaseNotes.inline("written in C# and F#")).isEmpty)
+ XCTAssertTrue(links(ReleaseNotes.inline("version #x and #")).isEmpty)
+ // An existing link keeps its own target and the reference inside it is not linked a second time.
+ XCTAssertEqual(links(ReleaseNotes.inline("[PR #7](https://example.com/p)")).map { [$0.0, $0.1] },
+ [["PR #7", "https://example.com/p"]])
+ }
+
+ func testCommitHashesStayText() {
+ XCTAssertTrue(links(ReleaseNotes.inline("fixed in 3526c2f1 and 1a8478b8")).isEmpty)
+ }
+
+ func testMarkdownAndBareURLs() {
+ let l = links(ReleaseNotes.inline("[brew](https://brew.sh) and https://example.com/a?b=1, then more"))
+ XCTAssertEqual(l.map { [$0.0, $0.1] }, [["brew", "https://brew.sh"], ["https://example.com/a?b=1", "https://example.com/a?b=1"]])
+ }
+
+ func testInlineStyles() {
+ let s = ReleaseNotes.inline("**bold** *it* `code`")
+ let intents = s.runs.compactMap { r -> (String, InlinePresentationIntent)? in r.inlinePresentationIntent.map { (String(s[r.range].characters), $0) } }
+ XCTAssertTrue(intents.contains { $0.0 == "bold" && $0.1.contains(.stronglyEmphasized) })
+ XCTAssertTrue(intents.contains { $0.0 == "it" && $0.1.contains(.emphasized) })
+ XCTAssertTrue(intents.contains { $0.0 == "code" && $0.1.contains(.code) })
+ XCTAssertEqual(String(s.characters), "bold it code")
+ }
+
+ // ---- Blocks ----
+
+ func testBlockKinds() {
+ let b = ReleaseNotes.blocks(from: "## Title\n\nA paragraph.\n\n- one\n* two\n continued\n\n---\n### Sub\n#155 is not a heading")
+ XCTAssertEqual(b.map(kind), ["heading", "paragraph", "bullet", "bullet", "heading", "paragraph"])
+ XCTAssertEqual(String(text(b[3]).characters), "two continued")
+ XCTAssertEqual(links(text(b[5])).map { $0.0 }, ["#155"])
+ }
+
+ func testBoldLeadingParagraphIsNotABullet() {
+ XCTAssertEqual(ReleaseNotes.blocks(from: "**Bold** start").map(kind), ["paragraph"])
+ }
+
+ // ---- v0.7.0's real body ----
+
+ func testRealBodyEnglish() throws {
+ let b = ReleaseNotes.blocks(from: ReleaseNotes.markdown(try Self.body(), for: .en))
+ let headings = b.filter { kind($0) == "heading" }.map { String(text($0).characters) }
+ XCTAssertEqual(headings, ["What this release does", "New", "Fixes", "Known issues", "Install", "Credits"])
+ XCTAssertFalse(b.contains { String(text($0).characters).contains("这一版做了什么") })
+ XCTAssertFalse(b.contains { String(text($0).characters).contains("`") || String(text($0).characters).contains("**") })
+ XCTAssertFalse(b.contains { String(text($0).characters).hasPrefix("- ") })
+ let all = b.map(text).flatMap(links)
+ XCTAssertTrue(all.contains { $0.0 == "#155" && $0.1 == "https://github.com/LNPANDY/NX2Apple/issues/155" })
+ XCTAssertTrue(all.contains { $0.0 == "#166" } && all.contains { $0.0 == "#205" })
+ XCTAssertTrue(all.contains { $0.0 == "#192" } && all.contains { $0.0 == "#196" })
+ // Code spans carry the code intent: `devicectl`.
+ let reinstall = try XCTUnwrap(b.map(text).first { String($0.characters).contains("devicectl") })
+ XCTAssertTrue(reinstall.runs.contains { String(reinstall[$0.range].characters) == "devicectl" && $0.inlinePresentationIntent?.contains(.code) == true })
+ // Bold: the lead of a bullet.
+ let console = try XCTUnwrap(b.map(text).first { String($0.characters).hasPrefix("Console mode") })
+ XCTAssertTrue(console.runs.first?.inlinePresentationIntent?.contains(.stronglyEmphasized) == true)
+ // Names in credits are bold, not mentions, and a `$(whoami)` stays in code.
+ XCTAssertFalse(all.contains { $0.1 == "https://github.com/v0lumehi" })
+ }
+
+ func testRealBodyChinese() throws {
+ let b = ReleaseNotes.blocks(from: ReleaseNotes.markdown(try Self.body(), for: .zh))
+ let headings = b.filter { kind($0) == "heading" }.map { String(text($0).characters) }
+ XCTAssertEqual(headings, ["这一版做了什么", "新增", "修复", "已知问题", "安装", "致谢"])
+ XCTAssertFalse(b.contains { String(text($0).characters).contains("Guided first-run") })
+ XCTAssertTrue(b.map(text).flatMap(links).contains { $0.0 == "#185" })
+ }
+
+ // ---- Visual QA ----
+
+ /// Opt-in native rendering for pull request screenshots (NX_LAUNCHER_CAPTURE_DIR).
+ @MainActor func testRenderUpdateSheetForScreenshots() throws {
+ guard let directory = ProcessInfo.processInfo.environment["NX_LAUNCHER_CAPTURE_DIR"] else { throw XCTSkip("Set NX_LAUNCHER_CAPTURE_DIR to capture native views") }
+ let output = URL(fileURLWithPath: directory)
+ try FileManager.default.createDirectory(at: output, withIntermediateDirectories: true)
+ let app = NSApplication.shared
+ app.setActivationPolicy(.accessory)
+ let body = try Self.body()
+ // The body as it is, and the middle of it (the code spans, the links and the Fixes section) as the sheet shows it scrolled.
+ let middle = "## New\n\n" + String(body[body.range(of: "- **Reinstall")!.lowerBound...body.range(of: "## Known issues")!.lowerBound])
+ + "\n---\n\n## 新增\n\n" + String(body[body.range(of: "- **不重构建")!.lowerBound...body.range(of: "## 已知问题")!.lowerBound])
+ for (name, lang, notes) in [("update-sheet-notes-en", Lang.en, body), ("update-sheet-notes-zh", Lang.zh, body),
+ ("update-sheet-notes-middle-en", Lang.en, middle), ("update-sheet-notes-middle-zh", Lang.zh, middle)] {
+ let m = BuildModel()
+ m.lang = lang
+ m.appUpdate = AppUpdate.Release(tag: "v0.7.0", url: "", digest: nil, notes: notes)
+ let width: CGFloat = 560, height: CGFloat = 640
+ let host = NSHostingView(rootView: UpdateSheet(m: m).frame(width: width, height: height))
+ let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: width, height: height), styleMask: [.titled], backing: .buffered, defer: false)
+ window.contentView = host
+ window.appearance = NSAppearance(named: .darkAqua)
+ window.orderFront(nil)
+ RunLoop.main.run(until: Date().addingTimeInterval(0.5))
+ host.layoutSubtreeIfNeeded()
+ let rep = try XCTUnwrap(host.bitmapImageRepForCachingDisplay(in: host.bounds))
+ host.cacheDisplay(in: host.bounds, to: rep)
+ try XCTUnwrap(rep.representation(using: .png, properties: [:])).write(to: output.appendingPathComponent(name + ".png"))
+ window.orderOut(nil)
+ }
+ }
+}
diff --git a/frontend/Tests/NSPortBuilderTests/UpdateSheetTests.swift b/frontend/Tests/NSPortBuilderTests/UpdateSheetTests.swift
index 6f8915e5..dcdd8d83 100644
--- a/frontend/Tests/NSPortBuilderTests/UpdateSheetTests.swift
+++ b/frontend/Tests/NSPortBuilderTests/UpdateSheetTests.swift
@@ -1,10 +1,20 @@
import XCTest
@testable import NSPortBuilder
-/// The update sheet's bilingual split (UpdateSheet.lines): the release bodies follow
+/// The update sheet's bilingual split (ReleaseNotes.lines, read here as the displayed text of each block): the release bodies follow
/// docs/RELEASE-NOTES-GUIDE.md — a bilingual heading, `**中文** …` / `**English** …` paragraphs, then
/// bullets that interleave. A Chinese reader must not get the English paragraph and vice versa.
final class UpdateSheetTests: XCTestCase {
+ /// What a reader sees: each block's text, bullets prefixed with "- ".
+ static func plain(_ notes: String, for lang: Lang) -> [String] {
+ ReleaseNotes.blocks(from: ReleaseNotes.markdown(notes, for: lang)).map {
+ switch $0 {
+ case .heading(let t), .paragraph(let t): return String(t.characters)
+ case .bullet(let t): return "- " + String(t.characters)
+ }
+ }
+ }
+
private let body = """
## 这一版做了什么 / What this release does
@@ -19,27 +29,27 @@ final class UpdateSheetTests: XCTestCase {
"""
func testChineseReaderGetsTheChineseParagraphNotTheEnglishOne() {
- let zh = UpdateSheet.lines(body, for: .zh)
+ let zh = Self.plain(body, for: .zh)
XCTAssertTrue(zh.contains { $0.contains("拷到手机上快得多") })
XCTAssertFalse(zh.contains { $0.contains("copies to a phone far faster") },
"the English paragraph must not reach a Chinese reader: \(zh)")
}
func testEnglishReaderGetsTheEnglishParagraphNotTheChineseOne() {
- let en = UpdateSheet.lines(body, for: .en)
+ let en = Self.plain(body, for: .en)
XCTAssertTrue(en.contains { $0.contains("copies to a phone far faster") })
XCTAssertFalse(en.contains { $0.contains("拷到手机上快得多") })
}
func testTheHeadingAppearsInBoth() {
for lang in [Lang.zh, Lang.en] {
- XCTAssertTrue(UpdateSheet.lines(body, for: lang).contains { $0.contains("这一版做了什么") }, "\(lang)")
+ XCTAssertTrue(Self.plain(body, for: lang).contains { $0.contains("这一版做了什么") }, "\(lang)")
}
}
func testBulletsGoToTheirOwnLanguage() {
- let zh = UpdateSheet.lines(body, for: .zh)
- let en = UpdateSheet.lines(body, for: .en)
+ let zh = Self.plain(body, for: .zh)
+ let en = Self.plain(body, for: .en)
XCTAssertTrue(zh.contains { $0.hasPrefix("- iOS 构建修好了") })
XCTAssertFalse(zh.contains { $0.hasPrefix("- The iOS build is fixed") })
XCTAssertTrue(en.contains { $0.hasPrefix("- The iOS build is fixed") })
@@ -47,12 +57,12 @@ final class UpdateSheetTests: XCTestCase {
func testAMonolingualBodyComesThroughWhole() {
let one = "## What changed\n\n- One thing.\n- Another thing."
- XCTAssertEqual(UpdateSheet.lines(one, for: .zh), ["What changed", "- One thing.", "- Another thing."])
+ XCTAssertEqual(Self.plain(one, for: .zh), ["What changed", "- One thing.", "- Another thing."])
}
func testMarkdownMarksAreStripped() {
let bold = "**中文** 见 **NX2Apple** 的设置。"
- XCTAssertEqual(UpdateSheet.lines(bold, for: .zh), ["见 NX2Apple 的设置。"])
+ XCTAssertEqual(Self.plain(bold, for: .zh), ["见 NX2Apple 的设置。"])
}
// The format used from 0.4.8 on: English in full, `---`, Chinese in full.
@@ -77,8 +87,8 @@ final class UpdateSheetTests: XCTestCase {
"""
func testTheTwoHalvesFormatGivesEachReaderItsOwnHalf() {
- let en = UpdateSheet.lines(twoHalves, for: .en)
- let zh = UpdateSheet.lines(twoHalves, for: .zh)
+ let en = Self.plain(twoHalves, for: .en)
+ let zh = Self.plain(twoHalves, for: .zh)
XCTAssertTrue(en.contains { $0.contains("installs to a paired device") })
XCTAssertFalse(en.contains { $0.contains("启动器可以装到配对设备") }, "English half leaked: \(en)")
XCTAssertTrue(zh.contains { $0.contains("启动器可以装到配对设备") })
@@ -86,8 +96,8 @@ final class UpdateSheetTests: XCTestCase {
}
func testTheTwoHalvesKeepTheirOwnHeadings() {
- let en = UpdateSheet.lines(twoHalves, for: .en)
- let zh = UpdateSheet.lines(twoHalves, for: .zh)
+ let en = Self.plain(twoHalves, for: .en)
+ let zh = Self.plain(twoHalves, for: .zh)
XCTAssertTrue(en.contains("What this release does"))
XCTAssertTrue(en.contains("Fixes"))
XCTAssertFalse(en.contains("这一版做了什么"))
@@ -108,7 +118,7 @@ final class UpdateSheetTests: XCTestCase {
English second.
"""
- XCTAssertTrue(UpdateSheet.lines(flipped, for: .en).contains { $0.contains("English second") })
- XCTAssertTrue(UpdateSheet.lines(flipped, for: .zh).contains { $0.contains("中文在前") })
+ XCTAssertTrue(Self.plain(flipped, for: .en).contains { $0.contains("English second") })
+ XCTAssertTrue(Self.plain(flipped, for: .zh).contains { $0.contains("中文在前") })
}
}