【发布时间】:2017-07-06 16:25:52
【问题描述】:
我正在尝试为我的 ios 应用程序首次部署到 itc,该应用程序现在包含一个 react-native 视图。 我使用
创建了包react-native bundle --entry-file index.ios.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
但我似乎无法弄清楚切换 jsCodeLocation 以使用新包的语法。我找到的大多数指南都在 obj-c 中,并且无法弄清楚我的命令有什么问题。当我在这里设置断点时,我发现它返回 jsCodeLocation nil。
func loadReactNativeView () {
//let jsCodeLocation : URL = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index.ios", fallbackResource: nil)
let jsCodeLocation = Bundle.main.url(forResource: "main", withExtension: "jsbundle", subdirectory: "ios")
let rootView : RCTRootView = RCTRootView(bundleURL: jsCodeLocation, moduleName: "HealthStorylines", initialProperties: [:], launchOptions: [:])
rootView.backgroundColor = #colorLiteral(red: 0.2745098174, green: 0.4862745106, blue: 0.1411764771, alpha: 1)
let frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height - 49)
rootView.frame = frame
self.view.addSubview(rootView)
}
非常感谢并需要有关如何调试的建议
【问题讨论】:
标签: ios swift react-native