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
8 changes: 4 additions & 4 deletions ios/ReactTestApp/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ final class ContentViewController: UITableViewController {

if sections.isEmpty {
#if targetEnvironment(simulator)
let keyboardShortcut = " (⌃⌘Z)"
let keyboardShortcut = " (⌃⌘Z)"
#else
let keyboardShortcut = ""
let keyboardShortcut = ""
#endif
sections.append(SectionData(
items: items,
Expand Down Expand Up @@ -245,9 +245,9 @@ final class ContentViewController: UITableViewController {
return "\(major).\(minor).\(patch)"
}()
#if USE_FABRIC
let fabric = " (Fabric)"
let fabric = " (Fabric)"
#else
let fabric = ""
let fabric = ""
#endif
return "React Native version: \(version)\(fabric)"
}
Expand Down
86 changes: 43 additions & 43 deletions ios/ReactTestApp/ReactInstance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ final class ReactInstance: NSObject, RCTBridgeDelegate {
private var bundleRoot: String?

#if USE_TURBOMODULE
private lazy var turboModuleManagerDelegate = RTATurboModuleManagerDelegate(bridgeDelegate: self)
private lazy var turboModuleManagerDelegate = RTATurboModuleManagerDelegate(bridgeDelegate: self)
#endif

override init() {
#if DEBUG
remoteBundleURL = ReactInstance.jsBundleURL()
remoteBundleURL = ReactInstance.jsBundleURL()
#endif

super.init()

#if USE_TURBOMODULE
RCTEnableTurboModule(true)
RCTEnableTurboModule(true)
#endif

RCTSetFatalHandler { (error: Error?) in
Expand Down Expand Up @@ -67,32 +67,32 @@ final class ReactInstance: NSObject, RCTBridgeDelegate {
)

#if os(iOS)
NotificationCenter.default.addObserver(
self,
selector: #selector(onRemoteBundleURLReceived(_:)),
name: .didReceiveRemoteBundleURL,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(onRemoteBundleURLReceived(_:)),
name: .didReceiveRemoteBundleURL,
object: nil
)
#else
NSAppleEventManager.shared().setEventHandler(
RCTLinkingManager.self,
andSelector: #selector(RCTLinkingManager.getUrlEventHandler(_:withReplyEvent:)),
forEventClass: AEEventClass(kInternetEventClass),
andEventID: AEEventID(kAEGetURL)
)
NSAppleEventManager.shared().setEventHandler(
RCTLinkingManager.self,
andSelector: #selector(RCTLinkingManager.getUrlEventHandler(_:withReplyEvent:)),
forEventClass: AEEventClass(kInternetEventClass),
andEventID: AEEventID(kAEGetURL)
)
#endif

#if USE_FLIPPER
if let flipper = FlipperClient.shared() {
flipper.add(FlipperKitLayoutPlugin(
rootNode: UIApplication.shared,
with: SKDescriptorMapper(defaults: ())
))
flipper.add(FKUserDefaultsPlugin(suiteName: nil))
flipper.add(FlipperKitReactPlugin())
flipper.add(FlipperKitNetworkPlugin(networkAdapter: SKIOSNetworkAdapter()))
flipper.start()
}
if let flipper = FlipperClient.shared() {
flipper.add(FlipperKitLayoutPlugin(
rootNode: UIApplication.shared,
with: SKDescriptorMapper(defaults: ())
))
flipper.add(FKUserDefaultsPlugin(suiteName: nil))
flipper.add(FlipperKitReactPlugin())
flipper.add(FlipperKitNetworkPlugin(networkAdapter: SKIOSNetworkAdapter()))
flipper.start()
}
#endif
}

Expand Down Expand Up @@ -120,15 +120,15 @@ final class ReactInstance: NSObject, RCTBridgeDelegate {
)

#if USE_TURBOMODULE
guard let bridge = RCTBridge(delegate: turboModuleManagerDelegate, launchOptions: nil) else {
assertionFailure("Failed to instantiate RCTBridge with TurboModule")
return
}
guard let bridge = RCTBridge(delegate: turboModuleManagerDelegate, launchOptions: nil) else {
assertionFailure("Failed to instantiate RCTBridge with TurboModule")
return
}
#else
guard let bridge = RCTBridge(delegate: self, launchOptions: nil) else {
assertionFailure("Failed to instantiate RCTBridge")
return
}
guard let bridge = RCTBridge(delegate: self, launchOptions: nil) else {
assertionFailure("Failed to instantiate RCTBridge")
return
}
#endif // USE_TURBOMODULE

surfacePresenterBridgeAdapter = RTACreateSurfacePresenterBridgeAdapter(bridge)
Expand Down Expand Up @@ -169,9 +169,9 @@ final class ReactInstance: NSObject, RCTBridgeDelegate {

private func entryFiles() -> [String] {
#if os(iOS)
let extensions = [".ios", ".mobile", ".native", ""]
let extensions = [".ios", ".mobile", ".native", ""]
#elseif os(macOS)
let extensions = [".macos", ".native", ""]
let extensions = [".macos", ".native", ""]
#endif

guard let bundleRoot = bundleRoot else {
Expand Down Expand Up @@ -217,12 +217,12 @@ final class ReactInstance: NSObject, RCTBridgeDelegate {
))

#if os(iOS) && !targetEnvironment(simulator)
devMenu.add(RCTDevMenuItem.buttonItem(withTitle: "Scan QR Code") {
NotificationCenter.default.post(
name: ReactInstance.scanForQRCodeNotification,
object: self
)
})
devMenu.add(RCTDevMenuItem.buttonItem(withTitle: "Scan QR Code") {
NotificationCenter.default.post(
name: ReactInstance.scanForQRCodeNotification,
object: self
)
})
#endif
}
}
Expand Down Expand Up @@ -252,9 +252,9 @@ final class ReactInstance: NSObject, RCTBridgeDelegate {
}

#if os(iOS)
typealias RTAView = UIView
typealias RTAView = UIView
#else
typealias RTAView = NSView
typealias RTAView = NSView
#endif

func createReactRootView(_ reactInstance: ReactInstance) -> (RTAView, String)? {
Expand Down
94 changes: 47 additions & 47 deletions ios/ReactTestApp/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,70 +58,70 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {

#if !ENABLE_SINGLE_APP_MODE

extension SceneDelegate {
var isRunningTests: Bool {
let environment = ProcessInfo.processInfo.environment
return environment["XCInjectBundleInto"] != nil
}
extension SceneDelegate {
var isRunningTests: Bool {
let environment = ProcessInfo.processInfo.environment
return environment["XCInjectBundleInto"] != nil
}

func scene(_ scene: UIScene,
willConnectTo _: UISceneSession,
options _: UIScene.ConnectionOptions)
{
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene
// `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see
// `application:configurationForConnectingSceneSession` instead).

guard !isRunningTests else {
return
}
func scene(_ scene: UIScene,
willConnectTo _: UISceneSession,
options _: UIScene.ConnectionOptions)
{
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene
// `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see
// `application:configurationForConnectingSceneSession` instead).

guard !isRunningTests else {
return
}

if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UINavigationController(
rootViewController: ContentViewController(reactInstance: reactInstance)
)
self.window = window
window.makeKeyAndVisible()
}
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UINavigationController(
rootViewController: ContentViewController(reactInstance: reactInstance)
)
self.window = window
window.makeKeyAndVisible()
}
}
}

#endif // !ENABLE_SINGLE_APP_MODE

// MARK: - Single-app extensions

#if ENABLE_SINGLE_APP_MODE

extension SceneDelegate {
func scene(_ scene: UIScene,
willConnectTo _: UISceneSession,
options _: UIScene.ConnectionOptions)
{
guard let windowScene = scene as? UIWindowScene else {
assertionFailure("Default scene configuration should have been loaded by now")
return
}
extension SceneDelegate {
func scene(_ scene: UIScene,
willConnectTo _: UISceneSession,
options _: UIScene.ConnectionOptions)
{
guard let windowScene = scene as? UIWindowScene else {
assertionFailure("Default scene configuration should have been loaded by now")
return
}

guard let (rootView, _) = createReactRootView(reactInstance) else {
assertionFailure()
return
}
guard let (rootView, _) = createReactRootView(reactInstance) else {
assertionFailure()
return
}

rootView.backgroundColor = UIColor.systemBackground
rootView.backgroundColor = UIColor.systemBackground

let viewController = UIViewController(nibName: nil, bundle: nil)
viewController.view = rootView
let viewController = UIViewController(nibName: nil, bundle: nil)
viewController.view = rootView

let window = UIWindow(windowScene: windowScene)
window.rootViewController = viewController
self.window = window
let window = UIWindow(windowScene: windowScene)
window.rootViewController = viewController
self.window = window

window.makeKeyAndVisible()
}
window.makeKeyAndVisible()
}
}

#endif // ENABLE_SINGLE_APP_MODE

Expand Down
Loading