ReactNative CodePush CodePush.bundleURL() 在 AppDelegate.swift 中为零

问题描述

我有一个项目(iOS-Swift、React Native)需要与 CodePush 集成。 (我之前有 3 个项目(RN、iOS-ObjC)集成成功)。

AppDelegate.swift

func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    let jsCodeLocation: URL
    
    AppCenter.start(withAppSecret: "cbxxxxxx-3xxx-4exx-xxd7-xxxxxxxxxced",services: [Analytics.self,Crashes.self])

    #if DEBUG
    jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index",fallbackResource:nil)
    #else
      jsCodeLocation = CodePush.bundleURL()!
    #endif
    
    let rootView = RCTRootView(bundleURL: jsCodeLocation as URL!,moduleName: "MyApp",initialProperties: nil,launchOptions: launchOptions)
  //...

应用程序在模拟器上启动时崩溃,控制台出错:

[CodePush] Loading JS bundle from (null)
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file MyApp/AppDelegate.swift,line 39

我不确定代码推送是否支持 React Native 中的 Swift?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)