Skip to content

Commit

Permalink
feat: migrate off RCTAppDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
okwasniewski committed Feb 18, 2025
1 parent 364dd5a commit 50c139b
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions template/ios/HelloWorld/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,36 @@ import React_RCTAppDelegate
import ReactAppDependencyProvider

@main
class AppDelegate: RCTAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
self.moduleName = "HelloWorld"
self.dependencyProvider = RCTAppDependencyProvider()
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

// You can add your custom initial props in the dictionary below.
// They will be passed down to the ViewController used by React Native.
self.initialProps = [:]
var reactNativeDelegate: ReactNativeDelegate?
var reactNativeFactory: RCTReactNativeFactory?

return super.application(application, didFinishLaunchingWithOptions: launchOptions)
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
let delegate = ReactNativeDelegate()
let factory = RCTReactNativeFactory(delegate: delegate)
delegate.dependencyProvider = RCTAppDependencyProvider()

reactNativeDelegate = delegate
reactNativeFactory = factory

window = UIWindow(frame: UIScreen.main.bounds)

factory.startReactNative(
withModuleName: "HelloWorld",
in: window,
launchOptions: launchOptions
)

return true
}
}

class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
override func sourceURL(for bridge: RCTBridge) -> URL? {
self.bundleURL()
}
Expand Down

0 comments on commit 50c139b

Please sign in to comment.