我正在开发一个iOS项目,其中包括MongoDB Stitch和React-Native。 MongoDB API是用Swift编写的,而React Native iOS结构是基于Objective-C的。因此,我决定将Objective-C项目转换为Swift,以便可以使用MongoDB的Swift API并通过RCTBridge与React Native进行通信。因此,我将项目转换为Swift,但是当我在Xcode中对其进行编译时,它将显示一个空白屏幕。我已经创建了AppDelegate.swift和ProjectName-Bridging-Header.h文件。
我正在使用React Native版本0.59.5
我已经在AppDelegate.swift文件中使用了这段代码
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
}
}