11import UIKit
22import React
33import React_RCTAppDelegate
4+ import ReactAppDependencyProvider
45
56@objcMembers
67open class ReactAppProvider : UIResponder , UIApplicationDelegate {
@@ -9,18 +10,22 @@ open class ReactAppProvider: UIResponder, UIApplicationDelegate {
910
1011 public var window : UIWindow ?
1112 public var reactNativeFactory : RCTReactNativeFactory ?
13+ public var reactNativeDelegate : ReactNativeDelegate ?
1214 public var moduleName : String = defaultName
1315
1416 var reactRootViewName : String = defaultName
1517
1618 public func setUpProvider(
1719 moduleName: String = ReactAppProvider . defaultName,
18- reactRootViewName: String = ReactAppProvider . defaultName,
19- reactNativeFactory: RCTReactNativeFactory ?
20+ reactRootViewName: String = ReactAppProvider . defaultName
2021 ) {
2122 self . moduleName = moduleName
2223 self . reactRootViewName = reactRootViewName
23- self . reactNativeFactory = reactNativeFactory
24+ let delegate = ReactNativeDelegate ( )
25+ let factory = RCTReactNativeFactory ( delegate: delegate)
26+ delegate. dependencyProvider = RCTAppDependencyProvider ( )
27+ reactNativeDelegate = delegate
28+ reactNativeFactory = factory
2429 window = MendixReactWindow ( frame: UIScreen . main. bounds)
2530 }
2631
@@ -64,3 +69,18 @@ open class ReactAppProvider: UIResponder, UIApplicationDelegate {
6469 return ReactHostHelper ( ) . module ( forName: name) as? T
6570 }
6671}
72+
73+
74+ public class ReactNativeDelegate : RCTDefaultReactNativeFactoryDelegate {
75+ public override func sourceURL( for bridge: RCTBridge ) -> URL ? {
76+ self . bundleURL ( )
77+ }
78+
79+ public override func bundleURL( ) -> URL ? {
80+ #if DEBUG
81+ RCTBundleURLProvider . sharedSettings ( ) . jsBundleURL ( forBundleRoot: " index " )
82+ #else
83+ Bundle . main. url ( forResource: " main " , withExtension: " jsbundle " )
84+ #endif
85+ }
86+ }
0 commit comments