【发布时间】:2015-12-09 19:13:05
【问题描述】:
我有一个可以与开发服务器完美配合的 react 本机应用程序。
我想从 xcode 项目中捆绑要在本地提供的应用程序。所以,我启动了开发服务器并运行了
curl 'http://localhost:8080/index.ios.bundle?platform=ios&dev=true' -o ios/main.jsbundle
这在我的 ios 文件夹中创建了一个名为 main.jsbundle 的新文件。然后我去了我的AppDelegate.m 并将我的jsCodeLocation 更改为
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
一切似乎都正确,但是当我从 xcode 构建项目时,我在模拟器顶部看到 Loading from bundled file ... 而没有其他任何内容。
从我看到的 chrome 调试器
Uncaught NetworkError: Failed to execute 'importScripts' on
'WorkerGlobalScope': The script at
'file:///Users/benconant/Library/Developer/CoreSimulator/Devices/3054F999-82…281E-90D6-410D-BC17-
81A6D1DFCA2A/Eastern%20Car%20Service.app/main.jsbundle' failed to
load.messageHandlers.executeApplicationScript @
debuggerWorker.js:18onmessage @ debuggerWorker.js:42
如果我单击文件路径,它会将我带到包含我的应用程序的所有 javascript 代码的捆绑包。不知道为什么这个包无法加载......它似乎与从服务器发送的包相同
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8080/index.ios.bundle?platform=ios&dev=true"];
仅供参考...我还尝试按照在https://facebook.github.io/react-native/docs/running-on-device-ios.html#content 找到的创建捆绑包的官方步骤进行操作,这导致了同样的错误。我的想法是,如果捆绑包是从我的开发服务器加载的,我应该确保我放入项目中的那个与那个相同。
【问题讨论】:
标签: ios objective-c xcode facebook react-native