Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
37e7adb
Initial commit
Mx-Iris Aug 13, 2024
4678f0a
Updates
Mx-Iris Aug 13, 2024
4611a2a
Updates
Mx-Iris Aug 14, 2024
06f09af
Updates
Mx-Iris Aug 14, 2024
590bb2b
WIP
Mx-Iris Aug 15, 2024
cb5aa02
WIP
Mx-Iris Aug 15, 2024
26ef0fa
Refactoring, can't compile for now
Mx-Iris Aug 16, 2024
8e0e225
WIP
Mx-Iris Aug 16, 2024
01fafbe
WIP
Mx-Iris Aug 16, 2024
cd4422f
WIP-Fix bugs and support NSSave/OpenPanel
Mx-Iris Aug 16, 2024
27c6152
WIP-Support WiFiFeature Case Study
Mx-Iris Aug 18, 2024
7278ccc
WIP
Mx-Iris Aug 18, 2024
61e1fff
WIP
Mx-Iris Aug 18, 2024
2ba32eb
Format
Mx-Iris Aug 19, 2024
e2c5db4
Common
Mx-Iris Aug 19, 2024
0c61b63
Remove unused code
Mx-Iris Aug 20, 2024
c2bdb0d
Remove unused code
Mx-Iris Aug 20, 2024
82c7737
Merge branch 'main' into appkit-navigation-common
stephencelis Aug 22, 2024
8e5e4e6
Integrate custom transaction
stephencelis Aug 22, 2024
2b91081
address fatal error
stephencelis Aug 22, 2024
cad947b
Round out animation
stephencelis Aug 23, 2024
e863c54
Update Package.swift
mbrandonw Aug 23, 2024
00ed18a
Update Package@swift-6.0.swift
mbrandonw Aug 23, 2024
df6eda7
Support AppKit Navigation
Mx-Iris Aug 24, 2024
04b6e54
Merge branch 'main' into appkit-navigation-navigation
Mx-Iris Aug 27, 2024
2228ad1
Update Sources/AppKitNavigationShim/include/shim.h
Mx-Iris Aug 27, 2024
47ac7b3
Update Sources/AppKitNavigation/Navigation/Sheet.swift
Mx-Iris Aug 27, 2024
6111e32
Update Sources/AppKitNavigation/Navigation/ModalSessionContent.swift
Mx-Iris Aug 27, 2024
3832d51
Fixes building errors
Mx-Iris Sep 17, 2024
8485f16
Merge remote-tracking branch 'upstream/main' into appkit-navigation-b…
Mx-Iris Oct 11, 2024
593cae8
Support control bindings
Mx-Iris Oct 11, 2024
2479dba
Translate some protocol to internal
Mx-Iris Oct 11, 2024
863c8d2
Completion
Mx-Iris Oct 11, 2024
2963dd1
Fixes
Mx-Iris Oct 11, 2024
9d0df7e
Fix errors
Mx-Iris Nov 30, 2024
6dbe303
Merge remote-tracking branch 'origin/appkit-navigation-navigation'
Mx-Iris Feb 4, 2025
ddd9af0
Merge remote-tracking branch 'origin/appkit-navigation-bindings'
Mx-Iris Feb 4, 2025
7f867ac
Merge remote-tracking branch 'upstream/main'
Mx-Iris Feb 4, 2025
567a607
Merge upstream main branch
Mx-Iris Feb 4, 2025
37fbfd4
Merge remote-tracking branch 'upstream/main'
Mx-Iris Sep 29, 2025
b57ed0f
Add NSProgressIndicator binding support
Mx-Iris Oct 8, 2025
5ed4d8e
Merge remote-tracking branch 'upstream/main'
Mx-Iris Jan 10, 2026
15d12e3
Fix error
Mx-Iris Jan 11, 2026
c1f2b2a
Merge remote-tracking branch 'upstream/main'
Mx-Iris Mar 19, 2026
4f27f7c
Merge remote-tracking branch 'upstream/main'
Mx-Iris Apr 24, 2026
919d32e
Merge remote-tracking branch 'upstream/main'
Mx-Iris Jun 24, 2026
4858204
Fix AppKitNavigation build under upstream changes
Mx-Iris Jun 24, 2026
eb2eaca
Add `popover` navigation for AppKit
Mx-Iris Jun 24, 2026
97b2ae1
Add `popover` support for `NSToolbarItem` (macOS 14+)
Mx-Iris Jun 25, 2026
3c81b10
Keep `_PopoverPresentation` alive across `NSPopover` lifecycle
Mx-Iris Jun 25, 2026
262edce
Merge tag '2.10.3'
Mx-Iris Jul 27, 2026
ad18e29
Make AppKitNavigation imports `public` for library evolution
Mx-Iris Jul 29, 2026
00ff13d
fix(appkit): keep the progress indicator's isAnimated binding alive
Mx-Iris Sep 5, 2026
f7b5724
feat(appkit): register an additional target-action pair on macOS 27
Mx-Iris Sep 5, 2026
98f78ff
Merge tag '2.11.2'
Mx-Iris Sep 5, 2026
3d7e519
fix(appkit): run closure actions once per click on macOS 27
Mx-Iris Nov 3, 2026
a142871
fix(appkit): reset the binding when the user dismisses a presented vi…
Mx-Iris Nov 3, 2026
d41f0c7
fix(appkit): let the binding end modal presentations, and reset it wh…
Mx-Iris Nov 3, 2026
416c369
fix(appkit): stop writing to a binding once it is unbound or replaced
Mx-Iris Nov 3, 2026
520738f
fix(appkit): keep forwarding responder-chain actions after taking ove…
Mx-Iris Nov 3, 2026
2d59cfd
fix(appkit): stop replacing AppKit's text-field selection handling
Mx-Iris Nov 3, 2026
49716a9
fix(appkit): report a text field's focus as soon as it gains it
Mx-Iris Nov 3, 2026
930b66c
fix(appkit): apply font panel changes to the bound font
Mx-Iris Nov 3, 2026
9149082
fix(appkit): validate taken-over menu and toolbar items like their or…
Mx-Iris Nov 3, 2026
c2175df
docs: record review findings that were not fixed, and why
Mx-Iris Nov 3, 2026
12af389
test(appkit): keep the AppKit test target compiling with Swift 6.2
Mx-Iris Nov 3, 2026
47cb9b6
Merge branch 'appkit-navigation-bug-fixes'
Mx-Iris Nov 3, 2026
6139da9
docs: record the decision not to report the UIKit selection defect up…
Mx-Iris Nov 3, 2026
f4ed140
chore: ignore .worktrees/
Mx-Iris Nov 3, 2026
da65875
docs: propose an AppKitNavigation cleanup
Mx-Iris Nov 4, 2026
98ec300
test(appkit): cover each typed control binding before the cleanup
Mx-Iris Nov 4, 2026
d6868bc
fix(appkit): clear the AppKitNavigation build warnings
Mx-Iris Nov 4, 2026
b460272
refactor(appkit): run font manager bindings through the shared action…
Mx-Iris Nov 4, 2026
964518e
docs: record the upstream warning the cleanup leaves in AppKitAnimation
Mx-Iris Nov 4, 2026
b5c3509
chore(appkit): drop the IdentifiedCollections dependency
Mx-Iris Nov 4, 2026
a5c7d48
refactor(appkit): name the Objective-C members added to AppKit classe…
Mx-Iris Nov 4, 2026
e5c0294
test(appkit): drop a redundant check from the method naming test
Mx-Iris Nov 4, 2026
96609a0
refactor(appkit): stop publishing a Sendable conformance for AnyCance…
Mx-Iris Nov 4, 2026
259b813
docs(appkit): replace the UIKit leftovers in the AppKitNavigation doc…
Mx-Iris Nov 4, 2026
75c6b54
docs: record that the AppKitNavigation cleanup is implemented
Mx-Iris Nov 4, 2026
a6daf2f
Merge branch 'appkit-navigation-cleanup'
Mx-Iris Nov 4, 2026
03f45a5
fix(appkit): stop the color panel binding from crashing on its first …
Mx-Iris Nov 4, 2026
049030e
Merge branch 'appkit-navigation-cleanup'
Mx-Iris Nov 4, 2026
e58c165
fix: clear the remaining Swift 6.4 warnings in SwiftNavigation and Ap…
Mx-Iris Nov 4, 2026
b17f3cd
fix(examples): import IssueReporting now that XCTestDynamicOverlay is…
Mx-Iris Nov 4, 2026
974c878
docs: record the warning and example fixes requested after review
Mx-Iris Nov 4, 2026
1b51ec6
Merge branch 'appkit-navigation-cleanup'
Mx-Iris Nov 4, 2026
8602608
docs: number the AppKitNavigation cleanup proposal 0001 and mark it i…
Mx-Iris Nov 4, 2026
add85dc
docs: propose keeping the main run loop alive under swift test
Mx-Iris Nov 5, 2026
6d427dd
test(appkit): keep the main run loop running when AppKit stops it fro…
Mx-Iris Nov 5, 2026
b23d732
test(appkit): compile the main run loop trait with Swift 6.2
Mx-Iris Nov 5, 2026
d4a7211
fix(appkit)!: label the path control initializer's binding url
Mx-Iris Nov 5, 2026
3d4912d
docs: record that the main run loop fix is implemented
Mx-Iris Nov 5, 2026
80a072f
Merge branch 'appkit-test-run-loop-exit'
Mx-Iris Nov 5, 2026
525f589
docs: number the main run loop fix proposal 0002 and mark it implemented
Mx-Iris Nov 5, 2026
0e16604
docs: propose typed bindings for common AppKit controls
Mx-Iris Nov 5, 2026
3dca0d6
refactor(appkit): let a binding leave out target-action or key-value …
Mx-Iris Nov 5, 2026
bf8a423
feat(appkit): bind a checkbox to a Bool or to set membership
Mx-Iris Nov 5, 2026
3ed6659
feat(appkit): bind a pop-up button or segmented control to one of sev…
Mx-Iris Nov 5, 2026
adbd5e3
feat(appkit): bind each segment of a segmented control to a Bool of i…
Mx-Iris Nov 5, 2026
46b5665
feat(appkit): bind whether a split view item is collapsed
Mx-Iris Nov 5, 2026
1fc4940
feat(appkit): bind a tab view controller's selected tab to one of sev…
Mx-Iris Nov 5, 2026
1afb453
feat(appkit): bind a menu item's checkmark to a Bool
Mx-Iris Nov 5, 2026
e29b823
docs(appkit): list the new control bindings and record that they are …
Mx-Iris Nov 5, 2026
7996f46
Merge branch 'appkit-common-control-bindings'
Mx-Iris Nov 5, 2026
74c2f94
docs: number the common control bindings proposal 0003 and mark it im…
Mx-Iris Nov 5, 2026
54cc10f
docs: propose selection and expansion bindings for table and outline …
Mx-Iris Nov 5, 2026
71de018
feat(appkit): bind a table's or an outline's selected row to an ident…
Mx-Iris Nov 5, 2026
eccd472
feat(appkit): bind an outline's expanded items to a set of identifiers
Mx-Iris Nov 5, 2026
765954c
docs(appkit): list the table and outline bindings and record that the…
Mx-Iris Nov 5, 2026
03bbd0a
Merge branch 'appkit-table-selection-bindings'
Mx-Iris Nov 5, 2026
09efa19
docs: number the table selection bindings proposal 0004 and mark it i…
Mx-Iris Nov 5, 2026
51eda42
docs: propose redesigning the AppKit presentation APIs
Mx-Iris Nov 6, 2026
b3cfe05
test(appkit): cover presentations and reproduce their defects
Mx-Iris Nov 6, 2026
d389a94
feat(appkit): run modals through one presentation lifecycle
Mx-Iris Nov 6, 2026
d01a4ae
feat(appkit): attach sheets through the shared presentation lifecycle
Mx-Iris Nov 6, 2026
8523a00
feat(appkit): show popovers through the shared presentation lifecycle
Mx-Iris Nov 6, 2026
d3b2356
feat(appkit): present view controllers through the shared presentatio…
Mx-Iris Nov 6, 2026
8871d68
refactor(appkit): remove the presentation code the shared lifecycle r…
Mx-Iris Nov 6, 2026
409a071
docs(appkit): document the presentation lifecycle and close the defer…
Mx-Iris Nov 6, 2026
e34c400
test(appkit): build the popover tests with compilers before Swift 6.4
Mx-Iris Nov 6, 2026
6f2abc3
Merge branch 'appkit-presentation-redesign'
Mx-Iris Nov 6, 2026
c63e05a
docs: number the presentation redesign proposal 0005 and mark it impl…
Mx-Iris Nov 6, 2026
036dfb8
refactor(appkit): rename ModalContent to WindowBackedContent
Mx-Iris Nov 7, 2026
9f4bd41
Merge branch 'appkit-window-backed-content'
Mx-Iris Nov 7, 2026
e867730
docs(examples): add AppKit case studies for presentations and selecti…
Mx-Iris Nov 7, 2026
63c7e38
Merge branch 'appkit-window-backed-content'
Mx-Iris Nov 7, 2026
67804fc
docs: number proposals 0006 and 0007 and mark them implemented
Mx-Iris Nov 7, 2026
9dd9804
docs: propose recommending unowned self in observe, a second batch of…
Mx-Iris Nov 9, 2026
137f1bc
docs(appkit): recommend capturing the owner unowned in observe and lo…
Mx-Iris Nov 9, 2026
52f41ff
feat(appkit): make items for bound options that follow the model, and…
Mx-Iris Nov 9, 2026
659c644
feat(appkit): bind a collection view's selection through a forwarding…
Mx-Iris Nov 9, 2026
b122dd6
docs(examples): show the new bindings and an animations case study, a…
Mx-Iris Nov 9, 2026
185b4ad
Merge branch 'appkit-more-control-bindings'
Mx-Iris Nov 9, 2026
cd541fb
docs: propose an optional AppKitPlus trait that brings stack navigati…
Mx-Iris Nov 9, 2026
9d573dd
docs: accept the AppKit stack navigation proposal
Mx-Iris Nov 9, 2026
63bcfbf
build: add an optional AppKitPlus trait to AppKitNavigation
Mx-Iris Nov 9, 2026
535bcaa
feat(appkit): add a path-driven NavigationStackController on top of A…
Mx-Iris Nov 9, 2026
aa20d32
feat(appkit): push navigation destinations from state, and let shown …
Mx-Iris Nov 9, 2026
1a14fdd
feat(appkit): bind table and outline selection through AppKitPlus dat…
Mx-Iris Nov 9, 2026
c70d2f0
docs(examples): turn on the AppKitPlus trait and add the AppKit stack…
Mx-Iris Nov 9, 2026
3a26cce
docs(appkit): document stack navigation with AppKitPlus, and build th…
Mx-Iris Nov 9, 2026
ec562ce
Merge branch 'appkit-stack-navigation'
Mx-Iris Nov 9, 2026
f0685ad
docs: number proposals 0008 to 0011 and mark them implemented
Mx-Iris Nov 10, 2026
935bcc3
fix(examples): add the macOS framework search path so the case studie…
Mx-Iris Nov 10, 2026
04be09e
fix(appkit): ignore the action a binding's own update sends
Mx-Iris Nov 14, 2026
5f37af8
refactor(appkit): follow view controller presentations without swizzling
Mx-Iris Nov 14, 2026
c4af197
refactor(appkit): write save and open panel choices without swizzling
Mx-Iris Nov 14, 2026
8be9c70
build(appkit): drop AppKitNavigationShim
Mx-Iris Nov 14, 2026
ce88ec8
fix(appkit): present modal windows and push while the window is minim…
Mx-Iris Nov 14, 2026
7cea303
docs(appkit): say what the presentation readiness checks actually loo…
Mx-Iris Nov 14, 2026
d095d47
docs: note the shim removal as implemented and awaiting review
Mx-Iris Nov 14, 2026
d5c309e
Merge branch 'appkit-remove-shim'
Mx-Iris Nov 14, 2026
62d70f4
docs: record that cancelling a save panel keeps its binding as it is
Mx-Iris Nov 14, 2026
172b83a
Merge branch 'appkit-remove-shim'
Mx-Iris Nov 14, 2026
0efd8aa
fix(appkit): report a binding's own dismissal as soon as AppKit returns
Mx-Iris Nov 14, 2026
8bff3e9
Merge branch 'appkit-remove-shim'
Mx-Iris Nov 14, 2026
65f6c0c
docs(examples): lay the AppKit case studies out as grouped forms and …
Mx-Iris Nov 14, 2026
885cde1
Merge branch 'appkit-examples-redesign'
Mx-Iris Nov 14, 2026
6644bd5
docs(examples): give the macOS case studies a sidebar and show every …
Mx-Iris Nov 14, 2026
b1c6a8e
Merge branch 'appkit-examples-redesign'
Mx-Iris Nov 14, 2026
4e19dd7
fix(examples): give the stack screens a background and let the AppKit…
Mx-Iris Nov 14, 2026
1d0e51d
Merge branch 'appkit-examples-redesign'
Mx-Iris Nov 14, 2026
3cb3333
docs(examples): record why a popped stack screen slides out blank, an…
Mx-Iris Nov 14, 2026
88be64a
Merge branch 'appkit-examples-redesign'
Mx-Iris Nov 14, 2026
19c0468
docs(examples): point the stack-transition follow-up at AppKitPlus 0116
Mx-Iris Nov 15, 2026
f65e26e
Merge branch 'appkit-examples-redesign'
Mx-Iris Nov 15, 2026
2578ffa
docs: number proposals 0012 and 0013 and mark them implemented
Mx-Iris Nov 15, 2026
ba88dbb
build(examples): pin AppKitPlus-Release 0.23.0
Mx-Iris Nov 15, 2026
7dad006
Merge branch 'examples-bump-appkitplus'
Mx-Iris Nov 15, 2026
d320479
build: require macOS 14
Mx-Iris Nov 15, 2026
0081ba0
Merge branch 'raise-macos-minimum'
Mx-Iris Nov 15, 2026
a9d9ba2
docs: record that the macOS 14 deprecation warnings stay for now
Mx-Iris Nov 15, 2026
14e60f0
Merge branch 'raise-macos-minimum'
Mx-Iris Nov 15, 2026
23bc265
docs: number proposal 0014 and mark it implemented
Mx-Iris Nov 15, 2026
66acb59
refactor(appkit): drop the requirements of WindowBackedContent
Mx-Iris Nov 27, 2026
89b056b
Merge branch 'appkit-window-backed-content-marker'
Mx-Iris Nov 27, 2026
2842089
docs: number proposal 0015 and mark it implemented
Mx-Iris Nov 27, 2026
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.worktrees/
69 changes: 69 additions & 0 deletions Documentations/Evolutions/0001-appkit-navigation-cleanup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 0001 - AppKitNavigation 清理:警告、重复代理和多余依赖

- **状态**: Implemented
- **创建日期**: 2026-11-04
- **最后更新**: 2026-11-04
- **实现分支**: `appkit-navigation-cleanup`

## 摘要

不改用法,把 AppKitNavigation 收拾干净:清掉 fork 自己代码里的 14 条编译警告(其中 3 条在以后的 Swift 语言模式里会变成错误),把 `NSFontManager` 复制出来的那一整套动作代理并回通用实现,去掉只为两个私有数组引入的 `IdentifiedCollections` 依赖,给加在 AppKit 类上的 `@objc` 成员加库前缀,收回一个没必要公开的遵循,删掉文档目录里从 UIKit 抄来的页面。起因是上一批修 bug 时,同样的两个问题要在两份代理里各修一遍;fork 的依赖和 lockfile 也比上游多出两个包。实现中发现 `NSColorPanel.bind(color:)` 一调用就崩溃,用户决定在这一批一起修掉;用户看过后,又要求修掉与上游共用代码里的警告和 Examples 的编译错误(第 9 步)。

## 方案

先补测试,再动代码:

1. **补测试作安全网**(已完成):每个类型化的 `bind`(开关、滑块、步进器、日期、颜色、路径、分段)各补一条双向测试,颜色面板除外(见决策日志);字体管理器补一条重新绑定的测试。`NSSavePanel.bind(url:)` 与 `NSOpenPanel.bind(urls:)` 靠交换私有方法 `setFinalURL:` / `setFinalURLs:` 工作,系统去掉它们时现在只会静默失效;补一条测试,让那种情况立即变红。
2. **清警告**(已完成):
- `NSControl`、`NSToolbarItem`、`NSColorPanel` 的 `@retroactive Sendable` 改成 `@unchecked @retroactive Sendable`,与 `NSMenuItem`、`NSFontManager` 一致。
- 两处没用在公开声明里的 `public import Combine` 改成内部导入。
- 上一批加的 `ControlActionDeliveryTests` 有 7 条并发警告:`makeControl()` 改为 `@MainActor`。
3. **合并字体管理器的代理**(已完成):删掉 `FontManagerProxy` 和 `NSFontManager` 扩展里复制的 `bind(_:to:set:)`,改走 `TargetActionProxy` 和同一份绑定实现。`NSFontManager.action` 是非可选的 `Selector`,遵循不了 `TargetActionProtocol`,所以只共享内部实现,公开签名不变。实际做法:`TargetActionProxy` 加一个接管字体管理器的构造器;绑定的主体提成内部函数 `establishBinding(_:to:of:through:set:)`,两边的 `bind(_:to:set:)` 都转给它。
4. **去掉 `IdentifiedCollections`**(已完成):动作列表改用普通数组。四份 `Package*.swift` 删掉这个依赖,`Package.resolved` 随之少掉 `swift-identified-collections` 和 `swift-collections`,依赖条目与上游一致(只剩 `originHash` 不同);两条 `public import IdentifiedCollections` 的警告一并消失。
5. **加库前缀**(已完成):`NSSwitch.boolValue`、`NSFontManager._selectedFont` 改成带 `appKitNavigation` 前缀的名字(`appKitNavigationIsOn`、`appKitNavigationSelectedFont`)。macOS 27.2 的 AppKit 里还没有同名方法,可一旦重名,Swift 扩展会悄悄替换掉系统实现——上一批修的 `textViewDidChangeSelection:` 就是这样坏的。两者都不是公开成员。另加一条测试守住这一类:扫描本库加在系统类上的 Objective-C 方法,名字里都要带库名,shim 有意替换的五个方法除外。
6. **收回 `AnyCancellable` 的公开 `Sendable` 遵循**(已完成):它只是为了在 `ObserveToken` 的闭包里捕获订阅,改用局部的 `nonisolated(unsafe) let`,库里已有同样的写法。
7. **文档**(已完成):删掉 `AppKitNavigation.docc` 里从 UIKit 抄来的 12 个页面(上游的 AppKitNavigation 没有它们),首页加一段概述和「绑定」「导航」两组目录;生成一次文档,确认没有新的 DocC 警告。实际还顺带修了 fork 自己的文档注释:文本框焦点绑定的示例和说明是从 UIKit 抄的,改成 AppKit 的写法;删掉不存在的参数说明,补上分段控件缺的参数说明。AppKitNavigation 的 DocC 警告从 23 条降到 3 条,剩下的都来自与上游共用的内容。
8. **修颜色面板绑定的崩溃**(已完成,实现中加入):`NSColorPanel` 遵循 `TargetActionProtocol` 时,`action` 的 getter 经 KVC 读面板的 action,而 KVC 返回不了 selector,抛出 `NSUnknownKeyException`;绑定在接管面板的 target/action 前要先读它,所以每次调用 `bind(color:)` 都崩溃。改为直接调用 AppKit 未公开但一直实现着的 `-action`,并用 `responds(to:)` 兜底。先补两条测试(面板能报出设置给它的 action;颜色面板的双向绑定),修之前崩溃,修之后通过。
9. **用户看过后追加的修复**(已完成):
- `AppKitAnimation.perform(_:completion:)` 的 `completion` 改为 `@Sendable`,消掉它被捕获进 `NSAnimationContext` 完成回调时的警告;唯一的调用方原本就只捕获 `Sendable` 的值。调用方原来的三目写法在 Swift 6.4 下会让类型检查器报「failed to produce diagnostic」,改成 `if` 赋值。
- `observe(_:)` 的两个重载在 Swift 6.4 上加 `@diagnose(ConversionFromIsolatedAnyToSynchronous, as: ignored, …)`(SE-0522),屏蔽「`@isolated(any)` 函数转成同步函数」的警告。这次同步转换是有意的:观察追踪要求同步执行;签名保留 `@isolated(any)`,因为上游靠它支持 `observe { @MainActor in … }` 这类显式指定隔离的写法。旧编译器不认这个属性,用 `#if hasAttribute(diagnose)` 包起来。
- Examples 里三处 `import XCTestDynamicOverlay` 改成 `import IssueReporting`,`XCTFail` 改成 `reportIssue`。上游把依赖升到 `swift-issue-reporting` 2.0 后,依赖图里不再有 `XCTestDynamicOverlay` 这个模块,CaseStudies 因此编不过。
- 工作区锁定文件 `SwiftNavigation.xcworkspace/xcshareddata/swiftpm/Package.resolved` 重新解析。原来那份和上游一样过时:钉着 `swift-case-paths` 的一个分支,还拉进旧地址的 `xctest-dynamic-overlay`,和 `swift-issue-reporting` 产品名冲突,命令行从零解析时直接失败。新的 pin 与 Xcode 实际解析出的版本一致。

没有询问就采用的假设:

- 公开 API 除第 6 条外不变。第 6 条严格说去掉了一个公开遵循;本机依赖这个 fork 的 7 个项目,都没有在 import AppKitNavigation 的文件里用 `AnyCancellable`,所以按轻量档处理。
- 这 7 个项目也都没有自己 import `IdentifiedCollections`,去掉依赖不影响它们。
- 保留 `TargetActionProtocol` 的 `Sendable` 要求和各控件的 `Sendable` 遵循:去掉它们才是真正的破坏性改动。
- 只动 fork 独有的文件,不碰与上游共用的 `SwiftNavigation` 和 UIKit 部分;四份清单的改动是向上游靠拢。
- 验证:Xcode 27.2 跑 AppKit 的全部测试,Xcode 26.6 编译 AppKit 的库和测试。
- 不在这一批:弹出相关三个文件(约 1,300 行)的重载收敛,连同 `Navigated.clearup()` 死代码(见 [ReviewDecisions.md](../Internal/ReviewDecisions.md)),属于大型重构,另起完整档提案;新功能各自另起提案。(已由 [0005](0005-appkit-presentation-redesign.md) 完成。)

## 后续项

- AppKit 的 Swift Testing 测试偶尔会中途结束,退出码却是 0,没跑完的测试结果就此丢失;`main` 上同样存在。用 lldb 查到:分段控件的 `performClick`、保存和打开面板的创建(`-[NSSavePanel _initBridgeAndStuff]` 等待远程面板的信号量)都会跑嵌套 run loop,偶尔把一个 `CFRunLoopStop` 漏给外层;而测试进程的主执行器在主 run loop 一返回就 `exit(0)`。去掉分段控件的点击用例不能根治,来源不止一处。修法要改测试基础设施,例如把这类测试移到 XCTest,或在主 run loop 退出时接着运行,留给另一批。(已修:在主 run loop 被误停时接着运行,见 [0002](0002-appkit-test-run-loop-exit.md)。)
- `NSPathControl` 的便捷构造器把 URL 绑定的参数标签写成了 `date:`,应为 `url:`;改它要动公开 API,不在这一批。(已修:直接改名为 `url:`,与 [0002](0002-appkit-test-run-loop-exit.md) 在同一分支上提交。)

## 决策日志

| 日期 | 决定 | 理由 |
|------|------|------|
| 2026-11-04 | Created as Draft | 修 bug 的那一批已落地,按审查清单的顺序接着处理优化项;这一批只收不改用法的清理 |
| 2026-11-04 | Accepted | 用户批准,开始实现 |
| 2026-11-04 | 第 1 步不含颜色面板的双向测试 | 写测试时发现 `NSColorPanel.bind(color:)` 一调用就崩溃(见后续项),崩溃的测试会中断整个测试进程;修它属于修 bug,不在这一批的范围里 |
| 2026-11-04 | 字体管理器补一条重新绑定的测试 | 第 3 步改动的正是解绑时移除回写动作的那段代码,现有测试没覆盖它 |
| 2026-11-04 | 现有的两条面板测试在调用私有方法前先确认它存在 | 方法不在时直接调用会让整个测试进程崩溃,金丝雀测试的结果也就看不到了 |
| 2026-11-04 | `AppKitAnimation.swift` 里的一条 `Sendable` 警告不改,记进 [ReviewDecisions.md](../Internal/ReviewDecisions.md) | 起草时的 14 条是增量构建统计的,漏了这个没重新编译的文件;用全新的构建目录重编一遍才看到它。它是与上游共用的代码,按上面的假设不碰 |
| 2026-11-04 | 第 5 步加一条命名测试,扫描本库加在系统类上的方法 | 只改两个名字,管不住以后再加的成员;测试先红(正好报出这两个成员的四个方法),改名后变绿 |
| 2026-11-04 | 命名测试放在主线程上跑 | 第一版没标 `@MainActor`:在后台线程写出 `NSView.self` 会在那条线程上执行 `+initialize`,让 AppKit 认错了线程。并行跑的其他测试随后在主线程处理事件时陷入断言陷阱,或者在打开面板时抛出 `already on an AppKit thread`,10 次里崩了 4 次;放到主线程后连跑 20 次没有再崩 |
| 2026-11-04 | 文档一步顺带修了 fork 自己的文档注释 | 生成文档时这些注释贡献了大部分 DocC 警告,而且文本框焦点绑定的示例是 UIKit 代码,照着写编不过 |
| 2026-11-04 | 实现完成,待用户看过后收尾 | 七步都已提交。Xcode 27.2 上 AppKit 测试全过(XCTest 16 条、Swift Testing 31 条),整个包只剩基线上本来就失败的 `ButtonStateTests.testAsyncAnimationWarning`;Xcode 26.6 编得过 AppKit 的库和测试;全新构建目录下 AppKit 只剩上游那一条警告。文档判断:README 不用改(用法没变);不需要使用指南或实现说明(没有新的调用契约);没有新术语;`swift-navigation-bindings` skill 不用改(公开用法没变) |
| 2026-11-04 | 颜色面板绑定的崩溃在这条分支上一起修(第 8 步) | 用户看过汇报后决定收尾前一起修,不另开一批 |
| 2026-11-04 | 修法:直接调用 AppKit 未公开的 `-action`,用 `responds(to:)` 兜底 | 让 getter 直接返回 `nil` 也不会崩,但绑定接管面板的 target/action 之后,就转发不了用户原先设的 action;改成监听颜色变化的通知、不再接管,又得改公开的 `TargetActionProtocol` 遵循。本机导出的 AppKit 头文件里,macOS 12.0.1、26.4–26.6、27.0、27.2 都有这个 getter。出问题的写法是 2024-10-11 加入颜色面板绑定时写下的,之后没改过,也没人修过;本机依赖这个 fork 的项目都没用到这个绑定 |
| 2026-11-04 | 测试进程中途以 0 退出的问题查明原因,不在这批修(见后续项) | 加入颜色面板测试后截断变得频繁,于是追查:问题出在 AppKit 嵌套 run loop 与测试进程主执行器的交互上,`main` 上本来就有;试着去掉分段控件的点击用例,并不能根治,已恢复原样。根治要改测试基础设施,超出这一批的范围 |
| 2026-11-04 | 第 8 步完成,重新验证 | Xcode 27.2 上 AppKit 测试完整跑通(Swift Testing 33 条、XCTest 16 条,有汇总行为证);Xcode 26.6 编得过 AppKit 的库和测试,只剩上游那一条警告 |
| 2026-11-04 | 按用户要求修与上游共用代码里的警告和 Examples 的编译错误(第 9 步) | 用户在 Xcode 里看到了这几条警告和 CaseStudies 的报错,要求一并修掉。这推翻了「只动 fork 独有的文件」那条假设,代价是以后合并上游时 `Observe.swift`、`AppKitAnimation.swift`、`UITransaction.swift` 和 Examples 可能冲突;原先记进裁决清单的「`AppKitAnimation.swift` 警告不修」随之删除 |
| 2026-11-04 | `observe(_:)` 用 `@diagnose` 屏蔽警告,不改签名 | 编译器对这类转换没有豁免写法,官方建议只有改成 async 或去掉 `@isolated(any)`:前者做不到(观察追踪必须同步),后者会让显式指定隔离的写法退化。代价是 Xcode 26.6(Swift 6.2)不认识这个属性,那两条警告在旧编译器上仍在,记进裁决清单 |
| 2026-11-04 | 工作区锁定文件一并更新 | 不更新的话,命令行和全新 clone 解析 Examples 的依赖时会因产品名冲突失败;新 pin 与 Xcode 里实际用的版本逐个核对过 |
| 2026-11-04 | 第 9 步完成,重新验证 | 全新构建目录下,Xcode 27.2 编 SwiftNavigation、AppKitNavigation 和 AppKit 测试零警告;整个包的测试只剩基线上的 `ButtonStateTests.testAsyncAnimationWarning`;CaseStudies 与 Inventory 用 xcodebuild 编 macOS 版成功(Inventory 关掉签名);Xcode 26.6 编得过 |
| 2026-11-04 | Implemented,编号 0001,落地到 `main` | 用户看过效果后要求收尾。九步全部完成;没做的两项留在后续项(测试进程中途以 0 退出、`NSPathControl` 构造器标签)。文档判断:不需要使用指南或实现说明,没有新的调用契约,难懂的决定都写在代码注释和本提案里;没有新术语;README 和 `swift-navigation-bindings` skill 不用改,公开用法没变 |
Loading
Loading