2

I'm developing an iOS Project which includes MongoDB Stitch and React-Native. MongoDB API is written in Swift and React Native iOS Structure is based on Objective-C. So I decided to convert Objective-C Project into Swift so that I can work with the Swift API of MongoDB and communicate with React Native via RCTBridge. So I converted the project into Swift but when I compile it in Xcode it shows a blank screen. I have created AppDelegate.swift and ProjectName-Bridging-Header.h files.

I'm using React Native Version 0.59.5

I have used this code in AppDelegate.swift file

import Foundation

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
  var window: UIWindow?
  var bridge: RCTBridge!

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    let jsCodeLocation: URL

    jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index.ios", fallbackResource:nil)
    let rootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "REPLACE_WITH_YOUR_PROJECT_NAME", initialProperties: nil, launchOptions: launchOptions)
    let rootViewController = UIViewController()
    rootViewController.view = rootView

    self.window = UIWindow(frame: UIScreen.main.bounds)
    self.window?.rootViewController = rootViewController
    self.window?.makeKeyAndVisible()

    return true
  }
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Amit Shetye
  • 133
  • 1
  • 11

0 Answers0