Today, when I was writing a simple RN demo, there were several mistakes, and finally I was able to solve the problem by sharing the pits and solutions I had stepped on:
1. An error occurred running: Could not connect to Development server.
Workaround:
Please put the APPDELEGATE.M in the project in the
Jscodelocation = [Nsurl urlwithstring:@ "http://localhost:8081/index.ios.bundle?platform=ios&dev= True"];
Switch
Jscodelocation = [Nsurl urlwithstring:@ "http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev= True"];
Cause: Do the local Area network development environment, most will do server mapping processing, localhost is pointing to a specific IP instead of native 127.0.0.1, this problem will occur.
2. "Unable to resolve module XXX from ..." in react native
There are two reasons for this error, one is that your dependency is not fully installed, and the other is that the code in your file is not written, such as the English letter is wrong.
If the dependency is not installed, you can refer to the following command:
NPM i XXX--save or NPM install
Then turn off the terminal and run it again.
3.IOS9 HTTPS mechanism to connect the network method:
First add the nsapptransportsecurity type dictionary in Info.plist. Then add the Nsallowsarbitraryloads type Boolean under Nsapptransportsecurity, The value is set to Yes.
4. Remember, most of my mistakes are the code is wrong, incredibly find a half-day reason, laugh and cry ...
Notes on the development of react native