IOS Real-Computer debuggingmethod One: (Access the development server from the device)
First of all, your laptop and your phone must be in the same WiFi network.
Open the IOS project's APPDELEGATE.M file
Change the localhost in jscodelocation to your computer's LAN IP address
In Xcode, select your phone as the target device and Run to
You can open the development menu (reload, debug, etc.) by shaking the device
Method Two: (Use offline package)
You can also package all the JavaScript code for the application itself. This way you can test it when the development server is not running and submit the application to AppStore.
-
Open ios/appdelegate.m
-
Follow the instructions for option 2:
-
cancel jscodelocation = [[NSBundle Mainbundle] urlforresource:@ "main" withextension:@ "Jsbundle"];
-
Runs the given at the terminal of your application's root directory,Curl command ($ Curl ' Http://localhost:8081/Game2048.bundle?platform=ios '-o main.jsbundle)//You should start the service locally at this time
-
//The JS file in the root directory of the package project to Main.jsbundle (you can package JavaScript directly using the above Curl method) $ react-native bundle [--minify]
Packager supports several options:
-
dev(Default True)--sets the__DEV__value of the variable. Whentrueit is, it will open a bunch of useful warnings. For products, it is recommended to usedev = false.
-
minify(False by default)--as long as the JS code is not transmitted via UGLIFYJS.
Trouble shooting
Ifcurlthe command fails, make sure the packager is running. Also try to add a flag at the end of it——ipv4.
If you have just started your project, itmain.jsbundlemay not be included in the Xcode project. To add it, right-click your project directory and click "Add Files ..."--Select the generatedmain.jsbundlefile.
Android Real-Computer debugging
Open the USB debugging on your Android device and connect to the computer to start debugging.
The method that runs on the real machine is consistent with running on the emulator, all through react-native run-android to install and run your react native app.
If not Android 5.0+ (API 21), then there is no way to debug through the ADB reverse, you need to connect to your developer server via WiFi
Let the debug computer and your phone must be in the same WiFi network below
Turn on vibrate menu (Shake device)
Go to Dev Settings
Select Debug Server Host for device
Enter the LAN IP for the debug computer
Click Reload JS
Xcode7 Error Resolution on the operating system
The XCODE7 specifies the real machine to run, the result is reported as follows error: (Undefined symbols for architecture arm64: "_rctsetlogfunction)
Undefined Symbols for Architecture arm64: ' _rctsetlogfunction ', referenced from:-[propertyfindertests testrenders Welcomescreen] in PROPERTYFINDERTESTS.O ld:symbol (s) isn't found for architecture arm64 clang:error:linker command failed With exit code 1 (use-v to see invocation)
set to No in Dead Code stripping, Build Setting, linking.
Real-Machine Debug error 2:
Invariant violation:application Game2048 have not been registered.
Some say it is port reason:
-
Kill already running program.
-
Or change the port by going into: then../lala/node_modules/react-native/packager/packager.jsfind your port number, example 8081, and replace with the port number that I s not in use.
-
var options = parsecommandline ([{command: ' Port ', default:8082,},
Some say it is appName registration reason :
Appregistry.registercomponent (' Awesomeproject ', () = yourmaincomponent);
var {appregistry} = React;
Others say it is a style reason :
Willposition: ' Absolute ' modified to position: ' Absolute '
Stylesheet.create ({cover: {display: ' Absolute '}});
None of the above has resolved my reasons :
Finally, after careful investigation, I found that I was still in the JavaScript packaging error. Clear the contents of the Main.bunndle, re-package JavaScript, Run--success. (Huang Tian not bear, finally succeeded, tears ran Ah!) )
At this point, IOS two methods are debugged, and the operation is complete. The former is generally used to develop the testing phase, which is used to package projects and publish AppStore.
PS (Reference):
Http://wiki.jikexueyuan.com/project/react-native/running-device.html
Http://facebook.github.io/react-native/docs/running-on-device-ios.html#content
https://github.com/facebook/react-native/issues/500#issuecomment-111575780
Http://stackoverflow.com/questions/29287987/invariant-violation-application-awesomeproject-has-not-been-registered-when-b
React Native Real-machine commissioning