如何在运行并调试React Native App

 

1. 进入工程目录,启动:Metro
   npx react-native start

 

2. 然后在新的terminal窗口中运行app

    npx react-native run-ios

第1,2步参考:https://reactnative.dev/docs/environment-setup#running-your-react-native-application

这时你的程序应该运行起来了。每次操作可以在显示Metro的窗口看到日志,包括console.log打印的结果。

3. 此时,可以在IOS Simulator窗口打开developer menu,打开方式有几种:
   a) Press Cmd-D on the keyboard. (对我不起作用)
   b) Press Cmd-Ctrl-Z on the keyboard.
   c) 在Simulator菜单 > Device > Shake (快捷键Cmd-Ctrl-Z)

 4. Debugging JS on Hermes using Google Chrome's DevTools
     See:  https://reactnative.dev/docs/hermes#debugging-js-on-hermes-using-google-chromes-devtools 

a) Navigate to chrome://inspect in a Chrome browser instance.
b) Use the Configure... button to add the Metro server address (typically localhost:8081 as described above).

        

 

TODO:  如何远程Debug,我还没实践,参考:https://reactnative.dev/docs/debugging

 

posted @   saaspeter  阅读(153)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示