IOS在设备上调试Realm提供的示例代码,不使用Chrome开发工具

时间:2018-06-12 08:40:58

标签: react-native realm react-devtools

严格遵循Realm's website

上列出的说明
  • react-native init myproj
  • cd myproj
  • npm install
  • npm install --save realm
  • react-native link realm

现在正在运行npm list以验证某些版本

  • react@16.3.1
  • react-native@0.55.4
  • realm@2.8.1

现在根据"狗的数量修改出货的App.js"在Realm的入门页面中的示例(直接替换类主体)。

现在在XCode(v9.4)中打开myproj.xcodeproj,修复签名错误。确保没有其他正在运行的捆绑程序线程。选择在xcode中连接的ipad mini并点击“构建并运行”

将应用程序加载到ipad mini后,我可以看到

 Number of dogs in theis Realm: 1

这意味着Realm已加载并正常运行。现在摇动ipad mini并点击" Debug JS Remotely"菜单,我在红色背景中收到此错误:

Failed to execute 'send' on 'XMLHttpRequest':Failed to load
'http://[IP_of_the_IPAD_mini]:8083/create_session'

Chrome React Native Debugger说"Status: Debugger session #10000 active",因此它已连接到ipad mini。

在我的iphone 7上进行了相同的测试,但得到了同样的错误。我确实需要进行设备调试,因为我们的项目需要使用设备的摄像头。有什么建议吗?

感谢。

1 个答案:

答案 0 :(得分:0)

here

中找到了一些线索

解决问题,打开RealmReact.mm文件,搜索

  

"访问控制允许来源"

并将该行更改为

[response setValue:@"*" forAdditionalHeader:@"Access-Control-Allow-Origin"];