Created
July 18, 2024 10:01
-
-
Save mdjastrzebski/592eee4ea182250b7b682a6736f46d8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import React | |
// Source: https://github.com/TMisiukiewicz/react-native-host-example/blob/main/ios/ReactNativeHostExample/BridgeManager.swift | |
class BridgeManager: NSObject { | |
static let shared = BridgeManager() | |
var bridge: RCTBridge? | |
public func loadReactNative(launchOptions: [AnyHashable: Any]?) { | |
bridge = RCTBridge(delegate: self, launchOptions: launchOptions) | |
} | |
} | |
extension BridgeManager: RCTBridgeDelegate { | |
func sourceURL(for bridge: RCTBridge) -> URL? { | |
#if DEBUG | |
return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index") | |
#else | |
return Bundle.main.url(forResource: "main", withExtension: "jsbundle") | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment