AppDelegate.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import UIKit
  2. import React
  3. import React_RCTAppDelegate
  4. import ReactAppDependencyProvider
  5. @main
  6. class AppDelegate: UIResponder, UIApplicationDelegate {
  7. var window: UIWindow?
  8. var reactNativeDelegate: ReactNativeDelegate?
  9. var reactNativeFactory: RCTReactNativeFactory?
  10. func application(
  11. _ application: UIApplication,
  12. didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
  13. ) -> Bool {
  14. let delegate = ReactNativeDelegate()
  15. let factory = RCTReactNativeFactory(delegate: delegate)
  16. delegate.dependencyProvider = RCTAppDependencyProvider()
  17. reactNativeDelegate = delegate
  18. reactNativeFactory = factory
  19. window = UIWindow(frame: UIScreen.main.bounds)
  20. factory.startReactNative(
  21. withModuleName: "ReactNativeMultip80",
  22. in: window,
  23. launchOptions: launchOptions
  24. )
  25. return true
  26. }
  27. }
  28. class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
  29. override func sourceURL(for bridge: RCTBridge) -> URL? {
  30. self.bundleURL()
  31. }
  32. override func bundleURL() -> URL? {
  33. #if DEBUG
  34. RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
  35. #else
  36. Bundle.main.url(forResource: "main", withExtension: "jsbundle")
  37. #endif
  38. }
  39. }