简体   繁体   English

调试本机应用程序

[英]Debugging react native Apps

I run into serious trouble debugging a react native app. 我在调试react native应用程序时遇到了麻烦。

  1. I installed the newest version of xCode as well as expo . 我安装了最新版本的xCode以及expo
  2. Start a iOS Simulator in xCode xCode启动iOS Simulator
  3. Create a new App/Project with expo (the one with the navbar) expo (带有导航栏的一个)创建一个新的App / Project。
  4. I send the project to the iOS Simulator which then opens the App. 我将项目发送到iOS Simulator ,然后打开该应用程序。

When I click Debug JS Remotely GoogleChrome opens and with the dev Tools I can work just as I am used to. 当我单击“ Debug JS Remotely将打开Goog​​leChrome,并使用dev Tools可以像以前一样工作。 However, when I add an error into the code, ie deleting a { , and then save the file, the App reloads (Hot Reloading) and I get an error (in the Simulator). 但是,当我在代码中添加错误(即删除{ ,然后保存文件)时,应用程序将重新加载(热重新加载),并且在模拟器中出现错误。 The error does not appear in the console of my GoogleChrome Browser. 该错误没有出现在我的GoogleChrome浏览器的控制台中。

  1. Why is that? 这是为什么?

Even worse, when I remove the error (here: adding the { where it belongs), and save the file, the App does not reload. 更糟糕的是,当我删除错误(此处:添加{所在的位置)并保存文件时,该应用程序不会重新加载。 I get errors like __fbBatchedBridge which are totally unrelated to the { -error. 我收到像__fbBatchedBridge这样的错误,它们与{ __fbBatchedBridge完全无关。 In order to get rid of these error I have to create a new Project with expo (which contains the code without the { -error) and send this to the iOS Simulator . 为了摆脱这些错误,我必须使用expo创建一个新项目(其中包含不带{ -error的代码),并将其发送到iOS Simulator Only then, the error (ie _fbBatchedBridge ) goes away. 只有这样,错误(即_fbBatchedBridge_fbBatchedBridge消失。

  1. Why do I have to create a new Project every time an error occurs. 为什么每次发生错误时都必须创建一个新项目。 There is something very wrong with this. 这有一点很不对劲。

I don't know exactly what kind of issue you are facing right now related to google chrome. 我不知道您目前面对的是与Google Chrome相关的问题。 But as you said the error _fbBatchedBrdige you don't need to create project again and again. 但是正如您所说的_fbBatchedBrdige错误,您不需要一次又一次地创建项目。 You have to comment the code in packager.sh file. 您必须注释packager.sh文件中的代码。

Check below path in your project 检查项目中的以下路径

node_modules/react-native/packager/packager.sh node_modules /反应天然/打包器/ packager.sh

Check for below code in packager.sh 检查packager.sh中的以下代码

 if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then     
      echo "Skipping bundling for Simulator platform"       
      exit 0;       
    fi

replace it with: 替换为:

#    if [[ "$PLATFORM_NAME" = "iphonesimulator" ]]; then        
#      echo "Skipping bundling for Simulator platform"      
#      exit 0;      
#    fi

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM