Skip to content

Commit 5dfb2e1

Browse files
SaadnajmiCopilot
andcommitted
feat(macos): migrate menu to SwiftUI App + .commands
Replace the programmatic AppKit menu bar (added in #2836) with the SwiftUI App lifecycle. SwiftUI provides the standard App/File/Edit/View/Window/Help menus for free, so the ~320 lines of makeMainMenu/make*MenuItem in WindowController.swift are deleted. The dynamic "React" menu is now declarative: ReactCommands renders a CommandMenu("React") driven by an observable AppModel. Publishing components/componentsEnabled/rememberLastComponent rebuilds the menu, so the manual NSMenuItem add/remove bookkeeping is gone. An AppDelegate is kept via @NSApplicationDelegateAdaptor for RN setup and lifecycle notifications. - AppDelegate.swift: @main App struct + adaptor + AppModel - ReactCommands.swift: dynamic React menu (Cmd-Shift-1..9 component shortcuts) - ViewController.swift: SwiftUI content hosting + placeholder - WindowController.swift: deleted - project.pbxproj / pack.test.mts: swap WindowController.swift for ReactCommands.swift Both ENABLE_SINGLE_APP_MODE and multi-app behavior are preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 7e96271 commit 5dfb2e1

7 files changed

Lines changed: 249 additions & 391 deletions

File tree

‎packages/app/macos/ReactTestApp.xcodeproj/project.pbxproj‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
193EF098247B130700BE8C79 /* ReactInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 193EF097247B130700BE8C79 /* ReactInstance.swift */; };
1717
1960F339258C97C400AEC7A2 /* Session.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1960F338258C97C400AEC7A2 /* Session.swift */; };
1818
196C22652490CBAB00449D3C /* React+Compatibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 196C22632490CBAB00449D3C /* React+Compatibility.m */; };
19-
199F3E152FF7AA0000270357 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 199F3E142FF7A9FB00270357 /* WindowController.swift */; };
19+
1900C0DE2FF9AA0000000002 /* ReactCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1900C0DE2FF9AA0000000001 /* ReactCommands.swift */; };
2020
19C4C89327710D8500157870 /* Manifest+Embedded.g.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C4C89227710D8500157870 /* Manifest+Embedded.g.swift */; };
2121
19E791C024B08E1400FA6468 /* ReactTestAppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E791BF24B08E1400FA6468 /* ReactTestAppTests.swift */; };
2222
19E791C324B08E4D00FA6468 /* ReactTestAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E791C224B08E4D00FA6468 /* ReactTestAppUITests.swift */; };
@@ -59,7 +59,7 @@
5959
1960F338258C97C400AEC7A2 /* Session.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Session.swift; path = ../Shared/Session.swift; sourceTree = "<group>"; };
6060
196C22632490CBAB00449D3C /* React+Compatibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "React+Compatibility.m"; path = "../Shared/React+Compatibility.m"; sourceTree = "<group>"; };
6161
196C22642490CBAB00449D3C /* React+Compatibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "React+Compatibility.h"; path = "../Shared/React+Compatibility.h"; sourceTree = "<group>"; };
62-
199F3E142FF7A9FB00270357 /* WindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; };
62+
1900C0DE2FF9AA0000000001 /* ReactCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReactCommands.swift; sourceTree = "<group>"; };
6363
19B368BC24B12C24002CCEFF /* ReactTestApp.common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ReactTestApp.common.xcconfig; sourceTree = "<group>"; };
6464
19B368BD24B12C24002CCEFF /* ReactTestApp.debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ReactTestApp.debug.xcconfig; sourceTree = "<group>"; };
6565
19B368BE24B12C24002CCEFF /* ReactTestApp.release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ReactTestApp.release.xcconfig; sourceTree = "<group>"; };
@@ -117,12 +117,12 @@
117117
isa = PBXGroup;
118118
children = (
119119
193EF062247A736200BE8C79 /* AppDelegate.swift */,
120+
1900C0DE2FF9AA0000000001 /* ReactCommands.swift */,
120121
193EF08E247A799D00BE8C79 /* Manifest.swift */,
121122
19C4C89227710D8500157870 /* Manifest+Embedded.g.swift */,
122123
193EF097247B130700BE8C79 /* ReactInstance.swift */,
123124
1960F338258C97C400AEC7A2 /* Session.swift */,
124125
193EF064247A736200BE8C79 /* ViewController.swift */,
125-
199F3E142FF7A9FB00270357 /* WindowController.swift */,
126126
193EF094247A84DA00BE8C79 /* ReactTestApp-Bridging-Header.h */,
127127
196C22642490CBAB00449D3C /* React+Compatibility.h */,
128128
196C22632490CBAB00449D3C /* React+Compatibility.m */,
@@ -315,10 +315,10 @@
315315
buildActionMask = 2147483647;
316316
files = (
317317
193EF063247A736200BE8C79 /* AppDelegate.swift in Sources */,
318+
1900C0DE2FF9AA0000000002 /* ReactCommands.swift in Sources */,
318319
193EF08F247A799D00BE8C79 /* Manifest.swift in Sources */,
319320
19C4C89327710D8500157870 /* Manifest+Embedded.g.swift in Sources */,
320321
196C22652490CBAB00449D3C /* React+Compatibility.m in Sources */,
321-
199F3E152FF7AA0000270357 /* WindowController.swift in Sources */,
322322
193EF098247B130700BE8C79 /* ReactInstance.swift in Sources */,
323323
1960F339258C97C400AEC7A2 /* Session.swift in Sources */,
324324
193EF093247A830200BE8C79 /* UIViewController+ReactTestApp.m in Sources */,

0 commit comments

Comments
 (0)