React Native Debugger Mac Download
2020年11月10日Download: http://gg.gg/mzn5p
This guide will help you get started on setting up your very first React Native for Windows app.
*This is only for Mac. If you aren’t using Mac for React Native dev - do it, it’s pretty great. Setting up a react native environment Steps Software installs and file setup Install Xcode from the app store - Xcode is a program that runs iOS apps for you, and lets you start a simulator for your app so you can develop without needing a physical.
*Available on Mac OS, Windows and Linux. Visual Studio Code. Runs everywhere. Have extensions market. Available on Mac OS, Windows and Linux. Nuclide or Atom. One of the best React Native IDE on Mac OS. Nuclide is built as single packet on top of Atom.
To develop Flutter apps for iOS, you need a Mac with Xcode installed. Install the latest stable version of Xcode (using web download or the Mac App Store ). Configure the Xcode command-line tools to use the newly-installed version of Xcode by running the following from the command line.
Make sure you have installed all of the development dependencies.
For information around how to set up React Native, see the React Native Getting Started Guide.Install React Native for Windows
Remember to call react-native init from the place you want your project directory to live.
To create TypeScript template, run npx react-native init <projectName> --template react-native-template-typescript@6.5.*.
If you’ve installed react native globally in the past, via npm install -g react-native, and are having issues with the new instructions, try adding --ignore-existing to your npx command:
npx --ignore-existing react-native init <projectName> --template react-native@^0.63.2 instead.Navigate into this newly created directory
Once your project has been initialized, React Native will have created a new sub directory where all your generated files live.Install the Windows extension
Lastly, install the React Native for Windows packages.
The --overwrite flag is a temporary measure that ensures the correct files are copied to metro.config.js for the metro bundler to work with Windows. If you are starting a new app, this should have no impact. If you are adding Windows to your existing app and you have modified the metro.config.js file, please back up your changes, run the command and copy over to take effect. We are tracking this issue here.
Here are the options that react-native-windows-init takes:OptionInput TypeDescription--helpbooleanShow help.--versionstringThe version of react-native-windows to use.--namespacestringThe native project namespace.--verbosebooleanEnables logging.--languagestring [’cs’, ’cpp’] [default: ’cpp’]Which language the app is written in.--overwritebooleanOverwrite any existing files without prompting.--useWinUI3booleanTargets WinUI 3.0 (Preview) instead of UWP XAML.Running a React Native Windows App
Make sure a browser is launched and running before running a React Native Windows app.Also ensure your system meets all the requirements to build a Windows app as well.
*
Without Using Visual Studio
In your React Native Windows project directory, run:
A new Command Prompt window will open with the React packager as well as a react-native-windows app. This step may take a while during first run since it involves building the entire project and all dependencies. You can now start developing! :tada:
*
Using Visual Studio
*Open the solution file in the application folder in Visual Studio (e.g., AwesomeProject/windows/AwesomeProject.sln if you used AwesomeProject as <projectName>)
*Select the Debug configuration and the x64 platform from the combo box controls to the left of the Run button and underneath the Team and Tools menu item.
*Run yarn start from your project directory, and wait for the React Native packager to report success.
*Click the Run button to the right of the platform combo box control in VS, or select the Debug->Start without Debugging menu item. You now see your new app and Chrome should have loaded http://localhost:8081/debugger-ui/ in a new tab. Press F12 or Ctrl+Shift+I in Chrome to open its Developer Tools. :tada:
*
With VS Code
*Open your applications folder in VS Code.
*Install the React Native Tools plugin for VS Code.
*Create a new file in the applications root directory, .vscode/launch.json and paste the following configuration:
*Press F5 or navigate to the debug menu (alternatively press Ctrl+Shift+D) and in the Debug dropdown select ’Debug Windows’ and press the green arrow to run the application.Authoring Native Modules
See Native Modules and React Native Windows.Building a standalone React Native Windows App
Follow these steps to build a version of your app that you can install or publish to the store. This version will package your bundle and assets into the appx package so you don’t need to run Metro.
*Open the solution in Visual Studio
*Select the Release configuration from the Configuration Manager dropdown.
*Build the solution. You can now launch without first launching Metro.
*If you want to build an appx package to share or publish, use the Project => Publish => Create App Packages.. option.
See also this article for additional details: https://techcommunity.microsoft.com/t5/windows-dev-appconsult/getting-started-with-react-native-for-windows/ba-p/912093#Accessing the In-App Developer Menu#
You can access the developer menu by shaking your device or by selecting ’Shake Gesture’ inside the Hardware menu in the iOS Simulator. You can also use the ⌘D keyboard shortcut when your app is running in the iOS Simulator, or ⌘M when running in an Android emulator on Mac OS and Ctrl+M on Windows and Linux. Alternatively for Android, you can run the command adb shell input keyevent 82 to open the dev menu (82 being the Menu key code).
The Developer Menu is disabled in release (production) builds.Enabling Fast Refresh#
Fast Refresh is a React Native feature that allows you to get near-instant feedback for changes in your React components. While debugging, it can help to have Fast Refresh enabled. Fast Refresh is enabled by default, and you can toggle ’Enable Fast Refresh’ in the React Native developer menu. When enabled, most of your edits should be visible within a second or two.Enabling Keyboard Shortcuts#
React Native supports a few keyboard shortcuts in the iOS Simulator. They are described below. To enable them, open the Hardware menu, select Keyboard, and make sure that ’Connect Hardware Keyboard’ is checked.LogBox#
Errors and warnings in development builds are displayed in LogBox inside your app.
LogBox is automatically disabled in release (production) builds.Console Errors and Warnings#
Console errors and warnings are displayed as on-screen notifications with a red or yellow badge, and the number of errors or warning in the console respectively. To view a console error or warnings, tap the notification to view the full screen information about the log and to paginiate through all of the logs in the console.
These notifications can be hidden using LogBox.ignoreAllLogs(). This is useful when giving product demos, for example. Additionally, notifications can be hidden on a per-log basis via LogBox.ignoreLogs(). This is useful when there’s a noisy warning that cannot be fixed, like those in a third-party dependency.
Ignore logs as a last resort and create a task to fix any logs that are ignored.LogBox.ignoreLogs([’Warning: ..’]);React Native Debugger Expo// Ignore all log notifications:Unhandled Errors#
Unhanded JavaScript errors such as undefined is not a function will automatically open a full screen LogBox error with the source of the error. These errors are dismissable and minimizable so that you can see the state of your app when these errors occur, but should always be addressed.Syntax Errors#
Syntax errors will automatically open a full screen LogBox error with the source of the syntax error. This error is not dismissable because it represents invalid JavaScript execution that must be fixed before continuing with your app. To dismiss these errors, fix the syntax error and either save to automatically dismiss (with Fast Refresh enabled) or cmd+r to reload (with Fast Refresh disabled).Chrome Developer Tools#
To debug the JavaScript code in Chrome, select ’Debug JS Remotely’ from the Developer Menu. This will open a new tab at http://localhost:8081/debugger-ui.
Select Tools → Developer Tools from the Chrome Menu to open the Developer Tools. You may also access the DevTools using keyboard shortcuts (⌘⌥I on macOS, CtrlShiftI on Windows). You may also want to enable Pause On Caught Exceptions for a better debugging experience.
Note: the React Developer Tools Chrome extension does not work with React Native, but you can use its standalone version instead. Read this section to learn how.Debugging using a custom JavaScript debugger#
To use a custom JavaScript debugger in place of Chrome Developer Tools, set the REACT_DEBUGGER environment variable to a command that will start your custom debugger. You can then select ’Debug JS Remotely’ from the Developer Menu to start debugging.
The debugger will receive a list of all project roots, separated by a space. For example, if you set REACT_DEBUGGER=’node /path/to/launchDebugger.js --port 2345 --type ReactNative’, then the command node /path/to/launchDebugger.js --port 2345 --type ReactNative /path/to/reactNative/app will be used to start your debugger.
Custom debugger commands executed this way should be short-lived processes, and they shouldn’t produce more than 200 kilobytes of output.Safari Developer Tools#
You can use Safari to debug the iOS version of your app without having to enable ’Debug JS Remotely’.
*Enable Develop menu in Safari: Preferences → Advanced → Select ’Show Develop menu in menu bar’
*Select your app’s JSContext: Develop → Simulator → JSContext
*Safari’s Web Inspector should open which has a Console and a Debugger
While sourcemaps may not be enabled by default, you can follow this guide or video to enable them and set break points at the right places in the source code.
However, every time the app is reloaded (using live reload, or by manually reloading), a new JSContext is created. Choosing ’Automatically Show Web Inspectors for JSContexts’ saves you from having to select the latest JSContext manually.React Developer Tools#
You can use the standalone version of React Developer Tools to debug the React component hierarchy. To use it, install the react-devtools package globally:
Note: Version 4 of react-devtools requires react-native version 0.62 or higher to work properly.
Now run react-devtools from the terminal to launch the standalone DevTools app:
It should connect to your simulator within a few seconds.
Note: if you prefer to avoid global installations, you can add react-devtools as a project dependency. Add the react-devtools package to your project using npm install --save-dev react-devtools, then add ’react-devtools’: ’react-devtools’ to the scripts section in your package.json, and then run npm run react-devtools from your project folder to open the DevTools.Integration with React Native Inspector#
Open the in-app developer menu and choose ’Toggle Inspector’. It will bring up an overlay that lets you tap on any UI element and see information about it:
However, when react-devtools is running, Inspector will enter a collapsed mode, and instead use the DevTools as primary UI. In this mode, clicking on something in the simulator will bring up the relevant components in the DevTools:
You can choose ’Toggle Inspector’ in the same menu to exit this mode.Inspecting Component Instances#
When debugging JavaScript in Chrome, you can inspect the props and state of the React components in the browser console.
First, follow the instructions for debugging in Chrome to open the Chrome console.
Make sure that the dropdown in the top left corner of the Chrome console says debuggerWorker.js. This step is essential.
Then select a React component in React DevTools. There is a search box at the top that helps you find one by name. As soon as you select it, it will be available as $r in the Chrome console, letting you inspect its props, state, and instance properties.Performance Monitor#
You can enable a performance overlay to help you debug performance problems by selecting ’Perf Monitor’ in the Developer Menu.Debugging Application State#
Office mac for ipad. Reactotron is an open-source desktop app that allows you to inspect Redux or MobX-State-Tree application state as well as view custom logs, run custom commands such as resetting state, store and restore state snapshots, and other helpful debugging features for React Native apps.
You can view installation instructions in the README. If you’re using Expo, here is an article detailing how to install on Expo.Projects with Native Code OnlyReact Native Debugger Ui
The following section only applies to projects with native code exposed. If you are using the managed expo-cli workflow, see the guide on ejecting to use this API.Accessing console logs#
You can display the console logs for an iOS or Android app by using the following commands in a terminal while the app is running:$ npx react-native log-android
You may also access these through Debug → Open System Log.. in the iOS Simulator or by running adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal while an Android app is running on a device or emulator.
If you’re using Create React Native App or Expo CLI, console logs already appear in the same terminal output as the bundler.Debugging on a device with Chrome Developer Tools#
If you’re using Create React Native App or Expo CLI, this is configured for you already.
On iOS devices, open the file RCTWebSocketExecutor.m and change ’localhost’ to the IP address of your computer, then select ’Debug JS Remotely’ from the Developer Menu.
On Android 5.0+ devices connected via USB, you can use the adb command line tool to setup port forwarding from the device to your computer:
adb reverse tcp:8081 tcp:8081React Native Debugger Windows
Alternatively, select ’Dev Settings’ from the Developer Menu, then update the ’Debug server host for device’ setting to match the IP address of your computer.
If you run into any issues, it may be possible that one of your Chrome extensions is interacting in unexpected ways with the debugger. Try disabling all of your extensions and re-enabling them one-by-one until you find the problematic extension.React Native Debugger Mac Download SoftonicDebugging native code#
When working with native code, such as when writing native modules, you can launch the app from Android Studio or Xcode and take advantage of the native debugging features (setting up breakpoints, etc.) as you would in case of building a standard native app.
Download: http://gg.gg/mzn5p
This guide will help you get started on setting up your very first React Native for Windows app.
*This is only for Mac. If you aren’t using Mac for React Native dev - do it, it’s pretty great. Setting up a react native environment Steps Software installs and file setup Install Xcode from the app store - Xcode is a program that runs iOS apps for you, and lets you start a simulator for your app so you can develop without needing a physical.
*Available on Mac OS, Windows and Linux. Visual Studio Code. Runs everywhere. Have extensions market. Available on Mac OS, Windows and Linux. Nuclide or Atom. One of the best React Native IDE on Mac OS. Nuclide is built as single packet on top of Atom.
To develop Flutter apps for iOS, you need a Mac with Xcode installed. Install the latest stable version of Xcode (using web download or the Mac App Store ). Configure the Xcode command-line tools to use the newly-installed version of Xcode by running the following from the command line.
Make sure you have installed all of the development dependencies.
For information around how to set up React Native, see the React Native Getting Started Guide.Install React Native for Windows
Remember to call react-native init from the place you want your project directory to live.
To create TypeScript template, run npx react-native init <projectName> --template react-native-template-typescript@6.5.*.
If you’ve installed react native globally in the past, via npm install -g react-native, and are having issues with the new instructions, try adding --ignore-existing to your npx command:
npx --ignore-existing react-native init <projectName> --template react-native@^0.63.2 instead.Navigate into this newly created directory
Once your project has been initialized, React Native will have created a new sub directory where all your generated files live.Install the Windows extension
Lastly, install the React Native for Windows packages.
The --overwrite flag is a temporary measure that ensures the correct files are copied to metro.config.js for the metro bundler to work with Windows. If you are starting a new app, this should have no impact. If you are adding Windows to your existing app and you have modified the metro.config.js file, please back up your changes, run the command and copy over to take effect. We are tracking this issue here.
Here are the options that react-native-windows-init takes:OptionInput TypeDescription--helpbooleanShow help.--versionstringThe version of react-native-windows to use.--namespacestringThe native project namespace.--verbosebooleanEnables logging.--languagestring [’cs’, ’cpp’] [default: ’cpp’]Which language the app is written in.--overwritebooleanOverwrite any existing files without prompting.--useWinUI3booleanTargets WinUI 3.0 (Preview) instead of UWP XAML.Running a React Native Windows App
Make sure a browser is launched and running before running a React Native Windows app.Also ensure your system meets all the requirements to build a Windows app as well.
*
Without Using Visual Studio
In your React Native Windows project directory, run:
A new Command Prompt window will open with the React packager as well as a react-native-windows app. This step may take a while during first run since it involves building the entire project and all dependencies. You can now start developing! :tada:
*
Using Visual Studio
*Open the solution file in the application folder in Visual Studio (e.g., AwesomeProject/windows/AwesomeProject.sln if you used AwesomeProject as <projectName>)
*Select the Debug configuration and the x64 platform from the combo box controls to the left of the Run button and underneath the Team and Tools menu item.
*Run yarn start from your project directory, and wait for the React Native packager to report success.
*Click the Run button to the right of the platform combo box control in VS, or select the Debug->Start without Debugging menu item. You now see your new app and Chrome should have loaded http://localhost:8081/debugger-ui/ in a new tab. Press F12 or Ctrl+Shift+I in Chrome to open its Developer Tools. :tada:
*
With VS Code
*Open your applications folder in VS Code.
*Install the React Native Tools plugin for VS Code.
*Create a new file in the applications root directory, .vscode/launch.json and paste the following configuration:
*Press F5 or navigate to the debug menu (alternatively press Ctrl+Shift+D) and in the Debug dropdown select ’Debug Windows’ and press the green arrow to run the application.Authoring Native Modules
See Native Modules and React Native Windows.Building a standalone React Native Windows App
Follow these steps to build a version of your app that you can install or publish to the store. This version will package your bundle and assets into the appx package so you don’t need to run Metro.
*Open the solution in Visual Studio
*Select the Release configuration from the Configuration Manager dropdown.
*Build the solution. You can now launch without first launching Metro.
*If you want to build an appx package to share or publish, use the Project => Publish => Create App Packages.. option.
See also this article for additional details: https://techcommunity.microsoft.com/t5/windows-dev-appconsult/getting-started-with-react-native-for-windows/ba-p/912093#Accessing the In-App Developer Menu#
You can access the developer menu by shaking your device or by selecting ’Shake Gesture’ inside the Hardware menu in the iOS Simulator. You can also use the ⌘D keyboard shortcut when your app is running in the iOS Simulator, or ⌘M when running in an Android emulator on Mac OS and Ctrl+M on Windows and Linux. Alternatively for Android, you can run the command adb shell input keyevent 82 to open the dev menu (82 being the Menu key code).
The Developer Menu is disabled in release (production) builds.Enabling Fast Refresh#
Fast Refresh is a React Native feature that allows you to get near-instant feedback for changes in your React components. While debugging, it can help to have Fast Refresh enabled. Fast Refresh is enabled by default, and you can toggle ’Enable Fast Refresh’ in the React Native developer menu. When enabled, most of your edits should be visible within a second or two.Enabling Keyboard Shortcuts#
React Native supports a few keyboard shortcuts in the iOS Simulator. They are described below. To enable them, open the Hardware menu, select Keyboard, and make sure that ’Connect Hardware Keyboard’ is checked.LogBox#
Errors and warnings in development builds are displayed in LogBox inside your app.
LogBox is automatically disabled in release (production) builds.Console Errors and Warnings#
Console errors and warnings are displayed as on-screen notifications with a red or yellow badge, and the number of errors or warning in the console respectively. To view a console error or warnings, tap the notification to view the full screen information about the log and to paginiate through all of the logs in the console.
These notifications can be hidden using LogBox.ignoreAllLogs(). This is useful when giving product demos, for example. Additionally, notifications can be hidden on a per-log basis via LogBox.ignoreLogs(). This is useful when there’s a noisy warning that cannot be fixed, like those in a third-party dependency.
Ignore logs as a last resort and create a task to fix any logs that are ignored.LogBox.ignoreLogs([’Warning: ..’]);React Native Debugger Expo// Ignore all log notifications:Unhandled Errors#
Unhanded JavaScript errors such as undefined is not a function will automatically open a full screen LogBox error with the source of the error. These errors are dismissable and minimizable so that you can see the state of your app when these errors occur, but should always be addressed.Syntax Errors#
Syntax errors will automatically open a full screen LogBox error with the source of the syntax error. This error is not dismissable because it represents invalid JavaScript execution that must be fixed before continuing with your app. To dismiss these errors, fix the syntax error and either save to automatically dismiss (with Fast Refresh enabled) or cmd+r to reload (with Fast Refresh disabled).Chrome Developer Tools#
To debug the JavaScript code in Chrome, select ’Debug JS Remotely’ from the Developer Menu. This will open a new tab at http://localhost:8081/debugger-ui.
Select Tools → Developer Tools from the Chrome Menu to open the Developer Tools. You may also access the DevTools using keyboard shortcuts (⌘⌥I on macOS, CtrlShiftI on Windows). You may also want to enable Pause On Caught Exceptions for a better debugging experience.
Note: the React Developer Tools Chrome extension does not work with React Native, but you can use its standalone version instead. Read this section to learn how.Debugging using a custom JavaScript debugger#
To use a custom JavaScript debugger in place of Chrome Developer Tools, set the REACT_DEBUGGER environment variable to a command that will start your custom debugger. You can then select ’Debug JS Remotely’ from the Developer Menu to start debugging.
The debugger will receive a list of all project roots, separated by a space. For example, if you set REACT_DEBUGGER=’node /path/to/launchDebugger.js --port 2345 --type ReactNative’, then the command node /path/to/launchDebugger.js --port 2345 --type ReactNative /path/to/reactNative/app will be used to start your debugger.
Custom debugger commands executed this way should be short-lived processes, and they shouldn’t produce more than 200 kilobytes of output.Safari Developer Tools#
You can use Safari to debug the iOS version of your app without having to enable ’Debug JS Remotely’.
*Enable Develop menu in Safari: Preferences → Advanced → Select ’Show Develop menu in menu bar’
*Select your app’s JSContext: Develop → Simulator → JSContext
*Safari’s Web Inspector should open which has a Console and a Debugger
While sourcemaps may not be enabled by default, you can follow this guide or video to enable them and set break points at the right places in the source code.
However, every time the app is reloaded (using live reload, or by manually reloading), a new JSContext is created. Choosing ’Automatically Show Web Inspectors for JSContexts’ saves you from having to select the latest JSContext manually.React Developer Tools#
You can use the standalone version of React Developer Tools to debug the React component hierarchy. To use it, install the react-devtools package globally:
Note: Version 4 of react-devtools requires react-native version 0.62 or higher to work properly.
Now run react-devtools from the terminal to launch the standalone DevTools app:
It should connect to your simulator within a few seconds.
Note: if you prefer to avoid global installations, you can add react-devtools as a project dependency. Add the react-devtools package to your project using npm install --save-dev react-devtools, then add ’react-devtools’: ’react-devtools’ to the scripts section in your package.json, and then run npm run react-devtools from your project folder to open the DevTools.Integration with React Native Inspector#
Open the in-app developer menu and choose ’Toggle Inspector’. It will bring up an overlay that lets you tap on any UI element and see information about it:
However, when react-devtools is running, Inspector will enter a collapsed mode, and instead use the DevTools as primary UI. In this mode, clicking on something in the simulator will bring up the relevant components in the DevTools:
You can choose ’Toggle Inspector’ in the same menu to exit this mode.Inspecting Component Instances#
When debugging JavaScript in Chrome, you can inspect the props and state of the React components in the browser console.
First, follow the instructions for debugging in Chrome to open the Chrome console.
Make sure that the dropdown in the top left corner of the Chrome console says debuggerWorker.js. This step is essential.
Then select a React component in React DevTools. There is a search box at the top that helps you find one by name. As soon as you select it, it will be available as $r in the Chrome console, letting you inspect its props, state, and instance properties.Performance Monitor#
You can enable a performance overlay to help you debug performance problems by selecting ’Perf Monitor’ in the Developer Menu.Debugging Application State#
Office mac for ipad. Reactotron is an open-source desktop app that allows you to inspect Redux or MobX-State-Tree application state as well as view custom logs, run custom commands such as resetting state, store and restore state snapshots, and other helpful debugging features for React Native apps.
You can view installation instructions in the README. If you’re using Expo, here is an article detailing how to install on Expo.Projects with Native Code OnlyReact Native Debugger Ui
The following section only applies to projects with native code exposed. If you are using the managed expo-cli workflow, see the guide on ejecting to use this API.Accessing console logs#
You can display the console logs for an iOS or Android app by using the following commands in a terminal while the app is running:$ npx react-native log-android
You may also access these through Debug → Open System Log.. in the iOS Simulator or by running adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal while an Android app is running on a device or emulator.
If you’re using Create React Native App or Expo CLI, console logs already appear in the same terminal output as the bundler.Debugging on a device with Chrome Developer Tools#
If you’re using Create React Native App or Expo CLI, this is configured for you already.
On iOS devices, open the file RCTWebSocketExecutor.m and change ’localhost’ to the IP address of your computer, then select ’Debug JS Remotely’ from the Developer Menu.
On Android 5.0+ devices connected via USB, you can use the adb command line tool to setup port forwarding from the device to your computer:
adb reverse tcp:8081 tcp:8081React Native Debugger Windows
Alternatively, select ’Dev Settings’ from the Developer Menu, then update the ’Debug server host for device’ setting to match the IP address of your computer.
If you run into any issues, it may be possible that one of your Chrome extensions is interacting in unexpected ways with the debugger. Try disabling all of your extensions and re-enabling them one-by-one until you find the problematic extension.React Native Debugger Mac Download SoftonicDebugging native code#
When working with native code, such as when writing native modules, you can launch the app from Android Studio or Xcode and take advantage of the native debugging features (setting up breakpoints, etc.) as you would in case of building a standard native app.
Download: http://gg.gg/mzn5p
コメント