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
3 changes: 2 additions & 1 deletion packages/app/ios/ReactTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
private weak var application: UIApplication?

@objc var window: UIWindow? {
@objc
var window: UIWindow? {
get {
// Copy the implementation of RCTKeyWindow() as it changes a lot upstream
if let connectedScenes = application?.connectedScenes {
Expand Down
17 changes: 0 additions & 17 deletions packages/app/macos/Localizations/en.lproj/Main.strings

This file was deleted.

22 changes: 4 additions & 18 deletions packages/app/macos/ReactTestApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
193EF063247A736200BE8C79 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 193EF062247A736200BE8C79 /* AppDelegate.swift */; };
193EF065247A736200BE8C79 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 193EF064247A736200BE8C79 /* ViewController.swift */; };
193EF067247A736300BE8C79 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 193EF066247A736300BE8C79 /* Assets.xcassets */; };
193EF06A247A736300BE8C79 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 193EF068247A736300BE8C79 /* Main.storyboard */; };
193EF08F247A799D00BE8C79 /* Manifest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 193EF08E247A799D00BE8C79 /* Manifest.swift */; };
193EF093247A830200BE8C79 /* UIViewController+ReactTestApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 193EF091247A830200BE8C79 /* UIViewController+ReactTestApp.m */; };
193EF098247B130700BE8C79 /* ReactInstance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 193EF097247B130700BE8C79 /* ReactInstance.swift */; };
1960F339258C97C400AEC7A2 /* Session.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1960F338258C97C400AEC7A2 /* Session.swift */; };
196C22652490CBAB00449D3C /* React+Compatibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 196C22632490CBAB00449D3C /* React+Compatibility.m */; };
199F3E152FF7AA0000270357 /* WindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 199F3E142FF7A9FB00270357 /* WindowController.swift */; };
19C4C89327710D8500157870 /* Manifest+Embedded.g.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19C4C89227710D8500157870 /* Manifest+Embedded.g.swift */; };
19E791C024B08E1400FA6468 /* ReactTestAppTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E791BF24B08E1400FA6468 /* ReactTestAppTests.swift */; };
19E791C324B08E4D00FA6468 /* ReactTestAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E791C224B08E4D00FA6468 /* ReactTestAppUITests.swift */; };
Expand Down Expand Up @@ -45,7 +45,6 @@
193EF062247A736200BE8C79 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
193EF064247A736200BE8C79 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
193EF066247A736300BE8C79 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = SOURCE_ROOT; };
193EF069247A736300BE8C79 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
193EF06B247A736300BE8C79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
193EF06C247A736300BE8C79 /* App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = App.entitlements; sourceTree = SOURCE_ROOT; };
193EF071247A736300BE8C79 /* ReactTestAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ReactTestAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -60,11 +59,11 @@
1960F338258C97C400AEC7A2 /* Session.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Session.swift; path = ../Shared/Session.swift; sourceTree = "<group>"; };
196C22632490CBAB00449D3C /* React+Compatibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "React+Compatibility.m"; path = "../Shared/React+Compatibility.m"; sourceTree = "<group>"; };
196C22642490CBAB00449D3C /* React+Compatibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "React+Compatibility.h"; path = "../Shared/React+Compatibility.h"; sourceTree = "<group>"; };
199F3E142FF7A9FB00270357 /* WindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowController.swift; sourceTree = "<group>"; };
19B368BC24B12C24002CCEFF /* ReactTestApp.common.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ReactTestApp.common.xcconfig; sourceTree = "<group>"; };
19B368BD24B12C24002CCEFF /* ReactTestApp.debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ReactTestApp.debug.xcconfig; sourceTree = "<group>"; };
19B368BE24B12C24002CCEFF /* ReactTestApp.release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ReactTestApp.release.xcconfig; sourceTree = "<group>"; };
19C4C89227710D8500157870 /* Manifest+Embedded.g.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Manifest+Embedded.g.swift"; sourceTree = SOURCE_ROOT; };
19E0B90C27E9F8FD006FD558 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = ../Localizations/en.lproj/Main.strings; sourceTree = "<group>"; };
19E791BF24B08E1400FA6468 /* ReactTestAppTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReactTestAppTests.swift; sourceTree = "<group>"; };
19E791C224B08E4D00FA6468 /* ReactTestAppUITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ReactTestAppUITests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -123,14 +122,14 @@
193EF097247B130700BE8C79 /* ReactInstance.swift */,
1960F338258C97C400AEC7A2 /* Session.swift */,
193EF064247A736200BE8C79 /* ViewController.swift */,
199F3E142FF7A9FB00270357 /* WindowController.swift */,
193EF094247A84DA00BE8C79 /* ReactTestApp-Bridging-Header.h */,
196C22642490CBAB00449D3C /* React+Compatibility.h */,
196C22632490CBAB00449D3C /* React+Compatibility.m */,
193EF092247A830200BE8C79 /* UIViewController+ReactTestApp.h */,
193EF091247A830200BE8C79 /* UIViewController+ReactTestApp.m */,
193EF06C247A736300BE8C79 /* App.entitlements */,
193EF066247A736300BE8C79 /* Assets.xcassets */,
193EF068247A736300BE8C79 /* Main.storyboard */,
193EF06B247A736300BE8C79 /* Info.plist */,
191A67872BDFD9E90094F246 /* PrivacyInfo.xcprivacy */,
19B368BC24B12C24002CCEFF /* ReactTestApp.common.xcconfig */,
Expand Down Expand Up @@ -248,7 +247,6 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = 193EF056247A736100BE8C79;
productRefGroup = 193EF060247A736200BE8C79 /* Products */;
Expand All @@ -269,7 +267,6 @@
files = (
191A67882BDFD9E90094F246 /* PrivacyInfo.xcprivacy in Resources */,
193EF067247A736300BE8C79 /* Assets.xcassets in Resources */,
193EF06A247A736300BE8C79 /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -321,6 +318,7 @@
193EF08F247A799D00BE8C79 /* Manifest.swift in Sources */,
19C4C89327710D8500157870 /* Manifest+Embedded.g.swift in Sources */,
196C22652490CBAB00449D3C /* React+Compatibility.m in Sources */,
199F3E152FF7AA0000270357 /* WindowController.swift in Sources */,
193EF098247B130700BE8C79 /* ReactInstance.swift in Sources */,
1960F339258C97C400AEC7A2 /* Session.swift in Sources */,
193EF093247A830200BE8C79 /* UIViewController+ReactTestApp.m in Sources */,
Expand Down Expand Up @@ -359,18 +357,6 @@
};
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
193EF068247A736300BE8C79 /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
193EF069247A736300BE8C79 /* Base */,
19E0B90C27E9F8FD006FD558 /* en */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
193EF083247A736300BE8C79 /* Debug */ = {
isa = XCBuildConfiguration;
Expand Down
44 changes: 33 additions & 11 deletions packages/app/macos/ReactTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,43 @@ import ReactTestApp_DevSupport

@main
final class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet var reactMenu: NSMenu!
@IBOutlet var rememberLastComponentMenuItem: NSMenuItem!
static func main() {
let delegate = AppDelegate()
let app = NSApplication.shared
app.delegate = delegate
app.run()
}

var reactMenu: NSMenu!
var rememberLastComponentMenuItem: NSMenuItem!

private(set) lazy var reactInstance = ReactInstance()

private lazy var mainWindow: NSWindow? = {
// `keyWindow` might be `nil` while loading or when the window is not
// active. Use `identifier` to find our main window.
let windows = NSApplication.shared.windows
return windows.first { $0.identifier?.rawValue == "MainWindow" }
}()
private lazy var windowController = WindowController()
private lazy var mainWindow = windowController.window

private var contentDidAppearToken: NSObjectProtocol?

func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool {
true
}

/// Builds the main menu and main window programmatically. This replaces
/// what used to be provided by `Main.storyboard`, and must run before the
/// rest of `applicationWillFinishLaunching(_:)` since it relies on
/// `reactMenu`/`rememberLastComponentMenuItem` and `mainWindow` being set.
private func initWindow() {
guard windowController.window != nil else {
fatalError("Failed to create window")
}

NSApp.mainMenu = makeMainMenu(title: Manifest.load().displayName)
}

func applicationDidFinishLaunching(_: Notification) {
windowController.showWindow(nil)
NSApp.activate()

NotificationCenter.default.post(
name: .ReactAppDidFinishLaunching,
object: nil
Expand Down Expand Up @@ -58,17 +76,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate {

// MARK: User interaction

@IBAction
@objc
func onLoadEmbeddedBundleSelected(_: NSMenuItem) {
reactInstance.remoteBundleURL = nil
}

@IBAction
@objc
func onLoadFromDevServerSelected(_: NSMenuItem) {
reactInstance.remoteBundleURL = ReactInstance.jsBundleURL()
}

@IBAction
@objc
func onRememberLastComponentSelected(_ menuItem: NSMenuItem) {
onRememberLastComponentSelectedInternal(menuItem)
}
Expand Down Expand Up @@ -149,6 +167,8 @@ extension AppDelegate {
}

func applicationWillFinishLaunching(_: Notification) {
initWindow()

// applicationWillFinishLaunching(_:) [ENABLE_SINGLE_APP_MODE=0]

if Session.shouldRememberLastComponent {
Expand Down Expand Up @@ -280,6 +300,8 @@ extension AppDelegate {
func initialize() {}

func applicationWillFinishLaunching(_: Notification) {
initWindow()

guard let window = mainWindow else {
assertionFailure("Main window should have been instantiated by now")
return
Expand Down
Loading
Loading