When I run a react-native project, I get a error no bundle URL present
, but I don\'t know what mistakes I do, I was very confused.
As instructed in the error message:
Agreeing to the Xcode/iOS license requires admin privileges, please run "sudo xcodebuild -license" and then retry this command.
Running the following command worked:
sudo xcodebuild -license
I had this issue happen for me as well...the issue was the packer wasn't running it seemed probably because my default shell was zsh. react-native tires to open a new terminal window and run .../node_modules/react-native/packager/launchPackager.command
but this didn't run. Manually running that (and keeping it running) fixed this for me.
I'm working with RN 0.49.5
.
I've tried lots of methods, but no one works. Finally i worked this out.
It's simple and easy.
Main idea is to change the localhost
to 127.0.0.1
, but it's not where the RN tells you. It's in RCTBundleURLProvider.m#- (BOOL)isPackagerRunning:(NSString *)host.
Changes of code:
oc
- NSString *host = ipGuess ?: @"localhost";
+ NSString *host = ipGuess ?: @"127.0.0.1";
This is ok for simulator. If it's device, just change the ip address to your machine's.
Just run in Terminal react-native start
:
cd your react native app directory/ react-native start
It will start up the packager, now don't close this terminal window, in another terminal window run your project. This is the only want that I found to get it working properly.
Be sure that your ATS settings are correct in .plist file.
You can find the file at /ios/{{project_name}}/Info.plist
localhost must be defined as exception request target like this:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
*(dont forget to remove this on release version..)
I had the same error and was able to run the app only through Xcode. react-native run-ios
did not work. To resolve the issue you need to remove the build
folder at YOUR_PROJECT/ios/build/
. After this you should be able to run your app through react-native run-ios
again. Hope this helps.