Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mdjastrzebski/592eee4ea182250b7b682a6736f46d8e to your computer and use it in GitHub Desktop.
Save mdjastrzebski/592eee4ea182250b7b682a6736f46d8e to your computer and use it in GitHub Desktop.
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