React-native: No bundle url present

Created on 7 Mar 2017  ·  192Comments  ·  Source: facebook/react-native

Description

I noticed some people recently asking about this "No bundle url present" error and I just faced it myself.

Reproduction

I had just run ˜react-native init projectName˜, setup my App.js file (a simple Hello World), called it in both iOS and Android indexes and run ˜react-native run-ios˜. Then the No bundle url present error appeared.

Solution

I tried to delete my node_modules and npm install, close the packager and run the project again, but it could only be solved when I follow the steps given here (http://stackoverflow.com/questions/42610070/what-means-of-no-bundle-url-present-in-react-native).

  • Run "react-native run-ios"
  • When the error appears, run "npm install"
  • Then run "react-native run-ios" again.

Additional Information

This is the first project I started using RN 0.42. Since it never happened before and I am not the only one facing this issue, I guess it should be taken a closer look to it.

Here's my package.json:

{
    "name": "myProject",
    "version": "0.0.1",
    "private": true,
    "scripts": {
        "start": "node node_modules/react-native/local-cli/cli.js start",
        "test": "jest"
    },
    "dependencies": {
        "react": "~15.4.1",
        "react-native": "0.42.0"
    },
    "devDependencies": {
        "babel-jest": "19.0.0",
        "babel-preset-react-native": "1.9.1",
        "jest": "19.0.2",
        "react-test-renderer": "~15.4.1"
    },
    "jest": {
        "preset": "react-native"
    }
}

If I can be more helpful to make any further test, it would be a pleasure.

Locked

Most helpful comment

My problem has been solved by adding NSAllowsLocalNetworking to Info.plist

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
        <key>NSAllowsLocalNetworking</key>
        <true/>
    </dict>
</key>

I am not sure it is because of RN0.42 or iOS issue, but it is solved in my case.

All 192 comments

Having the same issue now. Not sure what changed.

Same problem.

I believe it's an issue with XCode. That's he only thing I can figure. It updated and all hell broke loose.

Sent from my iPhone

On Mar 7, 2017, at 10:55 PM, Decade notifications@github.com wrote:

Same problem.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

What if you run npm start in console?

Same problem.

I found
JsCodeLocation = [[RCTBundleURLProvider jsBundleURLForBundleRoot:@ sharedSettings] "index.ios" fallbackResource:nil];
Take effective address not, this happens in connection to the network situation (and not all networks such), when this happens, disconnected from the network, I think, in a virtual machine can run in localhost:8081
This is the way I am

Nope. I tried everything.

Sent from my iPhone

On Mar 8, 2017, at 1:53 AM, Eugene Sokovikov notifications@github.com wrote:

What if you run npm start in console?


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

It worked fine with android

Sent from my iPhone

On Mar 8, 2017, at 2:13 AM, mac2066 notifications@github.com wrote:

Same problem.

I found
JsCodeLocation = [[RCTBundleURLProvider jsBundleURLForBundleRoot:@ sharedSettings] "index.ios" fallbackResource:nil];
Take effective address not, this happens in connection to the network situation (and not all networks such), when this happens, disconnected from the network, I think, in a virtual machine can run in localhost:8081
This is the way I am


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.

@AbeHerbert

Yes, this is the IOS code, I simply look at the code, here will automatically take the local IP, but obviously, did not take, Android I have not tried, but this is obviously different from the IOS code

My situation when I changed a network environment, it is normal, very clever, when I met the home
I try to print out the automatic access to the full address, are taken to return to the null, at the same time, APP will be waiting for the start of the case, this is the local address

NSLog (@ absoluteString:%@), [jsCodeLocation absoluteString]);
NSLog (@ host:%@), [jsCodeLocation host]);
NSLog (@ port:%@), [jsCodeLocation port]);

When I will

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

Modified into

jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];

This time can be a normal start, but after entering the application of remote image loading, it seems wrong
This is just a point of view, and there is no concrete solution

I have gotten that message when the packager is not running when the app is launched on iOS. Typically I have to completely kill the app and launch again after I have started the packager. Can you guys be sure that you have the packager running prior to launching the app?

@rmevans9 in my case the packager was running as always. The solution I posted is done while the packager and the app are running. That's the only way I found by now to handle this. I belive there's something going wrong when the modules are installed on react-native init. I have to do some tests before assurance it

Yes, the packager is already running. I can access it through the browser

I am also seeing this issue on RN 0.42.0

+1

Same problem and I run "npm install" and "react-native run-ios" ,the problem seems to be not solved yet.

I am seeing same problem @0.42.0 and
"npm install" does not solve it.

My problem has been solved by adding NSAllowsLocalNetworking to Info.plist

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
        <key>NSAllowsLocalNetworking</key>
        <true/>
    </dict>
</key>

I am not sure it is because of RN0.42 or iOS issue, but it is solved in my case.

Check if you have 127.0.0.1 localhost in your hosts, clean the project and retry, it worked for me.

Of course I do. I'm a web developer lol

Sent from my iPhone

On Mar 12, 2017, at 4:35 AM, AkiVer notifications@github.com wrote:

Check if you have 127.0.0.1 localhost in your hosts, clean the project and retry, it worked for me.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

I found a working solution, Give it a try. While the simulator is running don't close your bundler. Go to the path and run npm install then again react-native run-ios. It started working for me.

i faced this issues after i moved my project to another directory and run ios simulator

This is working for me: leave simulator running, leave the packager terminal window on, and run react-native run-ios again.

This also means the "Port already in use"

Terminating a process on port 8081

Run the following command on a Mac to find the id for the process that is listening on port 8081:

$ sudo lsof -i :8081

Then run the following to terminate the process:

$ kill -9 <PID>

please try troubleshooting in below link
https://facebook.github.io/react-native/docs/troubleshooting.html

Thanks,
Dhiraj

I'm just leaving this here, in case other people stumble upon the same cause.

In our team's case, during the migration to 0.42.0, we've accidentally removed the "Bundle React Native code and images" build phase from the XCode project.

Manually re-adding the phase solved the problem, but we're left scratching our heads as to when or how the phase was removed.

sglearner_xcodeproj

works for me when I build the app through xcode...

Same issue. Have set scheme to Release in Xcode and trying to archive the app for production, but main.jsbundle is not generating...

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 YOUR_PROJECT/ios/build/. After this you should be able to run your app through react-native run-ios again. Hope this helps.

For Debug configuration, which is default when new project is generated with react-native init command, build does not generate bundle file but instead uses packager for that. So the issue is related to network settings and is very likely related to proxy settings. If proxy is used, do not forget to set bypass proxy for localhost and 127.0.0.1 addresses.

Same here... Install the node packages again is not a proper solution

In my case it was because I was running Shadowsocks (being in China at the moment) and I didn't set it to bypass 127.0.0.1 and localhost. Thanks @om2pkral for mentioning that.

In my case, nothing was displayed on the other terminal that started up when react-native run-ios was executed.
It means that packager is not running.

So I was able to start packager by running PROJECT_DIR/node_modules/react-native/packager/launchPackager.command myself.
I run react-native run-ios again, it started up normally.

I don't know the cause, but the behavior of the open command below is doubtful.
https://github.com/facebook/react-native/blob/f48b54bf6211dbbdd32839b0de68b1d0a451e486/React/React.xcodeproj/project.pbxproj#L2421

Thanks to @om2pkral and @account-archived-270316 ,Shadowsocks in global mode cause the problem;If you're running a proxy then try to close it;

I moved from 42.0 to 42.2 and got this error with my test flight deployment. I deleted the build directory AND added <key>NSAllowsLocalNetworking</key>... <true/> and it started working again. Don't know which of the 2 was the magic though. I'm going to assume the 1st and remove the info.plist change.

I ran "react-native run-ios" in a second time, it went well.

check out your localhost
are you open ss? when i met this problem , i found i opened my vpn

I have a similar problem with RN 0.40, it cannot generate the bundle in release mode. It stops with error
`Worker Farm: Received message for unknown index for existing child. This should not happen!

SyntaxError: Unexpected token: punc (.)`
and I cannot understand where the error is, but is the react-native bundle step that fails

@yustada Adding the NSAllowsLocalNetworking key solved my problem but now my NSAllowsArbitraryLoads key doesn't seem to work anymore (I can't load http images anymore for example). Any idea?

I get the same issue. But I solved it, because I have open proxy. Maybe you can check if you open network proxy, and make sure you have shut it down.

Sorry for the stupid question, but what do you mean for open proxy? I don't think I opened any network proxy, but I guess it may be under the hood. How can I check it and shut it down?

Maybe we are in different environment . I don't have this issue yesterday and before, but get this error today cause have open a shadowsocks proxy soft ware which used to proxy. So when I turn it off, anything go ok. I don't know if you get the same problem. The RN app in local debug mode would download bundle from local host:localhost, so if I have use the network agency, it can not find local host. I dont know if you understand what I say? poor english.

@yustada your solution (here) solve my issue. I think put this parameter will fix something broken in Xcode. All my projects are not debuggable !

Apparently with the new version is working (2.8.13), I followed the various solutions and removed some problematic code from my project and it's better now. The problem is that uglify and in general the release environment are different from development environment. BUT uglify made it impossible to debug, to find out where the problem was I had to dig very deep to improve debugging.

In Mac, when I enable proxy will get this issue, disable proxy everything fine.

For me the issue was it couldn't create the JS bundle. It doesn't state the error when building from Xcode so there is no way for you to know this. To find the error run the following command.

react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output ./ios/release/main.jsbundle --assets-dest ./ios/release/main.jsbundle

For me the error was something with missing PureRenderMixin component. To which the solution can be found here: https://github.com/facebook/react-native/issues/13078. Basicly you have to manually install [email protected]. This can be done via running this command.

npm i --save [email protected]

This issue is now happening for everybody because newer versions of react alphas are being released (particularly alpha.5) and they are breaking react-native builds.

In the same way as @akiver, I solved the problem.

$ sudo vi /private/etc/hosts

# Add this line
127.0.0.1       localhost

I followed the steps outlined by @cutemachine, worked for me. Although prior to that, also did the usual rm -rf node_modules, reset packager cache.

2017-03-29 10 29 35

This is the problem of network agents, you can check whether the use of their own network over the wall tools

I put the Shadowsocks agent from the global model from the global model into automatic proxy mode on it

2017-03-29 10 30 53

And then react-native run-ios

2017-03-29 10 34 55

@Binb1
Have you tried NSAllowsArbitraryLoadsForMedia and NSAllowsArbitraryLoadsInWebContent?

Some ATS parameters have been added for iOS 10.0 and later and in macOS 10.12.
https://forums.developer.apple.com/thread/6767

I will randomly get this error for almost no reason (not running a proxy, not making any crazy project changes). To fix it I will delete my node_module, then re npm install and it works. But it is a little worrying that it happens so randomly.

@cutemachine method works for me too :) thanks

It worked for me when i launched the simulator from Xcode 🤔

@acomito
Probably because you are running the native port number 8081 is occupied, for example, use some other software, you can look at the next try

had to run sudo xcodebuild -license 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."

Works now

Ensure that your hosts file has 127.0.0.1 localhost in it. I found out that somehow I managed to delete it. Once I re-added it, the issue was resolved.

I have tried out React Native first time ever yesterday and the same problem has occured to me.

This is what I have already tried:

  • running "react-native run-ios" and during error "npm install" and re-run "react-native run-ios"
  • removing "node_modules/" and "npm install"
  • adding the above mentioned "NSAllowsLocalNetworking" stuff to Info.plist
  • running it through Xcode

Notes:

  • "127.0.0.1 localhost" is in my hosts
  • to my knowledge, I have never set up network proxies on this Mac
  • Node version: v6.4.0
  • Xcode version: 8.3 (8E162)
  • OS: macOS Sierra 10.12.3 (16D32)

Any help would be appreciated, thanks.

I got the same problem when i move the project to another empty folder.
but it can work when launched the simulator from Xcode.

finally solved by:

  1. remove the build folder YOUR_PROJECT/ios/build/
  2. run react-native run-ios got aother error, looks like building not finish. 😕
  3. run react-native run-ios again

@skywlkr @haikyuu maybe useful

do not edit info.plist.
cause simulator need a package import from localhost.

@lany44 unfortunately it still does not work. but thanks.

I tried pretty much every combination of solutions here and none of them worked. The only way I was able to get up and running was to open two terminal sessions in the project directory, run npm start in the first one, and then run react-native run-ios in the second.

I don't recall having to do that a month or two ago when I was first playing around with this - maybe there is a regression in how the packaging server is started if not already running?

@ngmiller Worked for me!

@ngmiller tried your solution too, but still not working. I'm starting to go mad.

@skywlkr Very frustrating. I wasted several hours on this yesterday. Maybe a dumb question, but have you tried from a completely fresh project?

yes, I have tried it with a totally new project

I have same issue as @skywlkr and get the same results. I've tried all the suggestions here but unfortunately none of them have worked.

I had this error and it was due to my xcode workspace file. I was lucky in that I hadn't done much work in the workspace, so I deleted it and now it builds.

POS WTF .. I am stuck with this shit for last 2 days. The guy above is right, I am running into exact same issue.

@ezos86 I totally get you. I will try to give it one more shot in the next days and will report back.

I got the same problem when I try duplicate Lightbox that make double providesModule the same name.

/**
 * @providesModule LightboxOverlay
 */

And I fix by remove providesModule then call react-native run-ios again.

Could somebody provide any clue? It would be greatly appreciated.

@skywlkr, I retried the solution mentioned by @mac2066 of changing the jsCodeLocation variable and it worked. I haven't tried it with an app that has local images, etc. so I may or may not run into issues there, but at least hello world works now on the Mac. More detailed info is here if you need it. Good luck.

@dcp12345678 thanks for the tip, it really works - at least as a temporary solution. also thanks @mac2066 for finding it out.

Upgrading bash (to latest 4.4.12) via Homebrew helped me. Use brew upgrade bash

@ngmiller That worked for me! Thank you!

I kept getting this happen to me after installing certain plugins.

I fixed it by doing this;

  1. npm cache clean
  2. react-native run-ios - this would run & then show the _No bundle url present_ error
  3. Re-run _(with simulator still running)_ react-native run-ios

Seems to fix whatever was happening & allows me to simulate from Xcode again

@hisshash Thanks, your solution worked.

In my case the problem was fixed by restarting the adb server: adb kill-server && adb start-server

@hisshash I also had to run react-native run-ios twice. react-native seems worryingly nondeterministic

I meet this problem in my project too, it is solved in the following way:
modify that area in your-project/ios/your-project-name/Info.plist:
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict/> </dict>
add the following comment in it:
<key>NSAllowsLocalNetworking</key> <true/>
at all,the total likes that,this problem end.
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict/> <key>NSAllowsLocalNetworking</key> <true/> </dict>

Are you using React-Native-Flux-Router?

I found the solution to my issue here:
http://stackoverflow.com/a/43875440/5439517

Delete "node_modules > react-native-router-flux > node_modules > react-native". Run react-native run-ios and it should work.

My main.jsbundle file wasn't being generated. The cause was that in the build phases step, the shell that xcode defaults to is /bin/sh which doesn't take my use of nvm into account. The script was silently failing for some reason, because it was running a much older version of node installed on my system, 0.10.22. Switching the shell to ZSH resulted in main.jsbundle being created for release builds
vibe_xcodeproj

@davidtrogers This 100% solved my issue too. I completely forgot about NVM.

I installed react-native onto my Mac machine today and ran into the same problem when running react-native run-ios for the second time and beyond. The workaround for me is rm -rf ios/build, but this will slow down my normal development cycle significantly.

Some points to note is that I install node through nvm instead of homebrew. Also, I am using yarn instead of npm for my package management. That means, I ran yarn global add react-native-cli instead of npm install -g react-native-cli and yarn install instead of npm install. This is worth noting because I don't see yarn mentioned at all in this Issue. Is there some sort of incompatibility that I just ran into?

Okay, I think I have narrowed down my issue to a specific 100% reproduction case.

This issue will only occur if I run react-native run-ios a subsequent time after I closed the terminal tab/window that React Packager had launched. The red emulator screen with the error message appears in this case. However, if I keep that React Packager tab/window open and run react-native run-ios again, the emulator will now launch the app without an error. Plus, all times I run react-native run-ios with the React Packager tab open, the emulator will always continue to function correctly.

A key observation to make is a correlation between whether the following output line in the React Packager tab appears and whether this issue occurs:

Bundling index.ios.js ... done.

This line will not appear when the emulator errors out with the "bundle url not present" message, but will appear when the emulator is successful.

I hope this helps. Annoying, but at least I found a way to speed up my development workflow. Perhaps this is a bug on React Packager?

first, ping 127.0.0.1 if 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.068 ms

second,ping localhost, if you localhost analysis ip is not your computer ip,we find the problem,reason:your localhost was modified,

third---you need modify your computer 127.0.0.1 with localhost, open /etc/hosts
and set for example: save,reload your Internet Explorer

1 ##
2 # Host Database
3 #
4 # localhost is used to configure the loopback interface
5 # when the system is booting. Do not change this entry.
6 ##
7 127.0.0.1 localhost

detai explain url:http://www.webkaka.com/tutorial/server/2013/121611/

@lishiping thanks for the suggestion, but that is not my problem. I have not modified my /etc/hosts file and I am able to ping localhost just fine.

RN = 0.43.3
Xcode = 8.3.2
MacOS = Sierra 10.12.5

I'm getting "No bundle url present." only when trying to run in release mode in xcode. I can run the app fine in debug mode.

I ran react-native bundle --platform ios --dev false --entry-file index.ios.js --bundle-output ios/main.jsbundle and it gives me the following error:

Unexpected token: keyword (default)

It doesn't show any line numbers or files that the error might be from. Is there a better way to get more context around this error?

I also tried removing build folder, npm run clean, remove node_modules folder, yarn install with no luck.

This same exact build was working for me a few days ago, so not sure what changed. I'm still on the same version of MacOS, xcode, and react native.

I am experiencing a similar problem as @zachrnolan is, although in my case, both Android and iOS are affected on our CI.

On android, builds fail during the :bundleReleaseJsAndAssets phase, giving me the Unexpected token: keyword (default) message.
On iOS, the builds succeed, but the bundle doesn't seem to be included because of this same error (which I could find somewhere in the huge xcodebuild logs).

This only seems to be happening for releases, and in my case I haven't been able to reproduce this locally in any way.

@zachrnolan the issue has fixed itself for me. Thought I'd let you know.

@stinodes I was able to fix this by upgrading watchman, very strange.

Here are the steps I took:

  • brew update
  • brew unlink watchman
  • brew install watchman
  • I ran npm run clean which I have set to do this:

    rm -rf ios/build; rm -rf ios/build; rm -rf android/build; rm -rf android/app/build; rm -rf $TMPDIR/react* ; rm -f ios/main.jsbundle; rm -rf node_modules; rm yarn.lock || true; npm cache clean; yarn cache clean

  • yarn install or npm install, if you aren't using yarn

Hopefully this helps others having the same issue. I also have a stack overflow post here: http://stackoverflow.com/questions/43993590/react-native-no-bundle-url-present-release-mode-only

Thanks @cutemachine , it's worked for me.

@zachrnolan an issue I have with your steps is that unlinking watchman and then installing it will not do anything. Furthermore, watchman will not even be in the PATH anymore because it is not linked. Here is the output from brew install watchman, which I expected:

$ brew install watchman
Warning: watchman-4.7.0 already installed, it's just not linked.

Nonetheless, after following your instructions, I am still running into this error. Hopefully someone from the React-Native core development team can help address this issue.

This is my first day using React Native and I'm still going through the Getting Started guide.
Whenever I just run react-native run-ios I get the error No bundle URL present.

I solve it by:

  • Checking previous React Native server sessions shutdown. If you run them on Port 8081 then kill it with:
kill $(lsof -t -i:8081)
  • Running the following instead of just react-native run-ios to delete iOS build directory before re-build.
rm -rf ios/build/; react-native run-ios
  • Combining the above and appending the commands to an alias in my Bash config file .bashrc
echo "alias rni=\"kill \$(lsof -t -i:8081); rm -rf ios/build/; react-native run-ios\"" >> ~/.bashrc
source ~/.bashrc

Now I can run the React Native iOS build with just the command without worrying about the common red error screens of death:


I wonder why React Native just gives users this error instead of just making the developer's life easier by automatically rectifying the error and reloading?

I get the same error/red screen again, "No bundle URL present" but this time the cause was a syntax error in my JS. I think one of the problems is that the error isn't appearing in the packager's output and the bundler is failing silently. The only indication I have that the bundle isn't being generated is from the Xcode output below:

movie_recording

vibe_xcworkspace

davidtrogers_ _davidtrogers__macbook-pro-3__68_3_13_5_ _tmux_-2_at_ _238x62

I am running zsh with nvm on MacOS 10.12.4. I downloaded react native for the first time 2 days ago, and installed watchman 2 days ago, so I assume I am running the newest versions.

I get the same red screen whenever I run react-native run-ios.

If I just run that command, a new terminal window is popped open but nothing _seems_ to happen and then I get that red screen of death with the same notification. lsof -t -i:8081 returns nothing. So it would seem react-native run-ios is not starting the packager.

However, if in a separate window/tmux pane I run npm start, then the packager starts running, and then run react-native run-ios all is well in the world and everything starts fine.

So I think react-native run-ios in the most recent versions of mac/xcode/react-native, the packager does not start.

This issue has grown a bit out of control, and I am not confident that everyone here is running into the same issue. This has to do with the fact that the error can show up for any one of multiple reasons.

I highly encourage you to open a new issue if you run into this and are confident that a solution is not already provided in this thread.

@ powercoder23 when I try your method I get :
manager psoulages$ kill -9
-bash: syntax error near unexpected token `newline'

Why is this closed when it is still happening?

Facing same issue.

Just installed everything and created new app on my Mac as per documentation. On executing react-native run-ios gives error similar to screens above.

How we are going create an full app if we are getting error on first run for simple documented example :(

@sukhvir1313 Yes, it's embarrassing, and would turn away newbies and even experienced developers.

@hramos, wouldn't the issue thread only get closed after summarising who solved the issue and how? If the problem is due to an ambiguous error message that could show up for one of multiple reasons, then why don't we just add this common issue to the React Native FAQ, provide a link to it in this thread, and then create an Action item of providing the opportunity for an open source developer to update the relevant parts of the React Native codebase to provide more specific and meaningful error messages, particularly if its affecting so many users, even brand new users. If I had some guidance I'd be more than happy to try and help fix this problem, but where do I start?

I've the same bundle issue ("No bundle url present").
Try this command, in the project root folder.
react-native upgrade
and then
react-native run-ios
It worked to me.

@ltfschoen this issue has become a catch-all for anything that results in a "No bundle URL" error. It's hardly actionable. By encouraging a new issue to be opened for anyone running into this, we can hopefully focus on identifying any actual remaining bugs. As for the FAQ, I defer to the active people on this thread.

Ensure your default shell is bash, because of export NODE_BINARY=node command needed.

check out your localhost at hosts file at "/etc/hosts"
in my case, resolving the localhost to 127.0.0.1 completely solved the problem

@coolboy88 the fix you are suggesting in /etc/hosts has already been suggested in this Issue. And it has already been reported in this Issue that doing so is not enough to fix the problem, including in my own case.

@coolboy88 & @ecbrodie : Suggestion from coolboy88 worked for me. Thanks :)

Had the same issue here. What was happening on my setup was a permission problem, I had to run the following command at project folder:
sudo chown -R myuser:staff myfolder
After that react-native run-ios and it ran successfully.

When i suffered it, i solved with follow

rm -rf ios/build
react-native run-ios

First time I ever ran into any issues using the "init" command. Tonight, I received the 'No bundle url present' error. This was on a brand new iMac, fresh OSX install and new version of Xcode.

After going thru various posts here, I assumed that it (the simulator) needed to be able to access localhost:8081 which the packager was running on. For some reason, Safari was not resolving localhost and neither was the iOS Simulator (though other browsers were fine). Still haven't figured it out and I just ended up modifying the AppDelegate.m to use 127.0.0.1 instead (thanks to a post above):

jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];

I'm not sure if this is a really good solution tbh (not a fan of harcoding). But it worked.

For me run the second time, everything went well! :) cheers

@colorfulberry, after renaming my project, your answer helped, thx

It just worked for me adding export REACT_NATIVE_FSOP_TIMEOUT=150000 to "Bundle React Native code and images" Build Phase. Default value is 15000 and my app had VR stuff and a 60MB MP4.

I encounter this error almost every time after running react-native run-ios. My solution:
Keep packager and simulator running, and just run react-native run-ios again in terminal.

As @Adamnator92 said, I received the same error when I renamed my project directory. I had some uppercase letters and renamed the directory to be all lowercase when this issue started. When I renamed it to back to having the original uppercase letters, everything started working again.

I was experiencing no issues yesterday then I loaded the app up again today and got this error.

I changed NSAppTransportSecurity as @yustada mentioned above, and it built. Then I changed it back, and it built successfully again. I'm very confused as to how this happened.

No problem when I build via xcode.

See: https://www.youtube.com/watch?v=e-2KARCog18

I just encountered this issue again after getting it to work last week, using a combination of the different solutions here (including downgrading to v0.44.2)

Now this morning my signing certificate expired, and I had to generate a new one in Xcode. Without changing anything else, it stopped working after building the app with the new certificate.

Running rm -rf node_modules and then npm install seemed to fix it

You can sometimes get this error if you don't run npm link

I renamed index.ios.js to index.js and this error pops up for Xcode release run. Renaming it back to index.ios.js solves the problem.

i encountered the same because in my app i was loading WebView with src from local file.
after modifying my Info.plist with solution from @yustada fixed my problem.


NSExceptionDomains

localhost

NSExceptionAllowsInsecureHTTPLoads


NSAllowsArbitraryLoads

NSAllowsArbitraryLoadsInWebContent

NSAllowsLocalNetworking

(for iOS)
In my case, I could run on simulator, but failed on device or release build.
It was because my script was missing from Build Phases and jsbundle was not generated.
I added "Bundle React Native code and images" script like this: (Shell: /bin/sh)

export NODE_BINARY=node
../node_modules/react-native/packager/react-native-xcode.sh

*"packager" could be "scripts" based on react-native version. You can check /node_modules/react-native/ folder and choose existing one.

After looking through all of these comments, I found no solution worked for me. My packager terminal has an es6 spread error and I believe its tied to issue #14858. I am running the following:

node: 6.11.1
npm: 3.10.10
react-native: 0.46.3

I hope they resolve this issue soon, because I can't even get a sample app off the ground and running. Feel like that's a major problem

check your network proxy config.

don't use shadowsocks global mode is word for me.

I ran into this issue after stopping the simulation and wanting to start it again. I had killed the simulation by using sudo lsof -i:8081 and kill -9 <pid> on the returned pids from the first command.

The fix literally was to run react-native run-ios three times. Each time it progressed further.

Mostly posting this to give a heads up that you may simply want to try using the run command several times before concluding anything else is wrong.

<key>NSExceptionDomains</key>
 <dict>
      <key>localhost</key>
      <dict>
           <key>NSExceptionAllowsInsecureHTTPLoads</key>
           <true/>
      </dict>
 </dict>

-- Sometimes on release we change localhost to the domain of our api we just change it back on debug scheme to localhost. works for us.

I literally tried everything for this to work and it ultimately came down to closing out XCode and restarting my Mac.

npm 4.2.0
node v8.0.0
react-native-cli 2.0.1
macOS 10.12.5

image
以上的方法都不能解决我这个问题。。。怎么办

For me this was a result of using yarn to install ignite, and then doing npm install. Since ignite requires yarn, everything works great if I run yarn add rather than npm install. So, overall, you could run into issues if you are using different package managers.

Remove the build folder and build again worked for me.

rm -rf ios/build
react-native run-ios

I had the same issue as @cesarkawakami : the "Bundle React Native code and images" was gone from my Build Phases tab in XCode when upgrading from 0.45 to 0.46.

After looking at my project.pbxproj file, it turns out that the react-native-git-upgrade command did change the definition of the "Bundle React Native code and images" phase, changed its id, but failed to update the Build Phase list with the new id.

If you have the same issue, you can search for the "Bundle React Native code and images" string in your project.pbxproj file and make sure that the ids match.

@pvanliefland - Can you please state the steps in changing "Bundle React Native code and images". I've been stuck in this problem for weeks and have tried the steps mention above but nothing seems working. When I created a sample project and tried running it, the simple project is working fine.

npm start solved this problem for me. Any idea why this was not called automatically on react-native run-ios ?

@Amritakeshre - did you able to run it on release mode?

run:
watchman watch-del-all
then run:
npm start

Hi all,

I am getting this error with the latest React Native version when running

"react-native run-ios"

Tried different ways, just couldn't work :(

Unpacking /Users/eric/.rncache/glog-0.3.4.tar.gz...

/Users/eric/Documents/Codes/react-native/Test123/node_modules/react-native/scripts/ios-install-third-party.sh:
line 28: /Users/eric/Documents/Codes/R: No such file or directory

/Users/eric/Documents/Codes/react-native/Test123/node_modules/react-native/scripts/ios-install-third-party.sh:
line 28:
D/react-native/Test123/node_modules/react-native/scripts/ios-configure-glog.sh:
No such file or directory

* BUILD FAILED *

The following commands produced analyzer issues:
Analyze
/Users/eric/Documents/Codes/react-native/Test123/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.c

Analyze

/Users/eric/Documents/Codes/react-native/Test123/node_modules/react-native/ReactCommon/yoga/yoga/YGNodeList.c
(2 commands with analyzer issues)

The following build commands failed:
PhaseScriptExecution Install Third Party
/Users/eric/Documents/Codes/react-native/Test123/ios/build/Build/Intermediates/React.build/Debug-iphonesimulator/double-conversion.build/Script-190EE32F1E6A43DE00A8543A.sh
(1 failure)

Installing build/Build/Products/Debug-iphonesimulator/Test123.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain,
code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier
build/Build/Products/Debug-iphonesimulator/Test123.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Any solid solution to solve this?

Thanks.

On Wed, Sep 6, 2017 at 5:41 PM, 丶尘殇 notifications@github.com wrote:

run:
watchman watch-del-all
then run:
npm start


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/12754#issuecomment-327431741,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AXIFs549pH9SyL5pF9jfirI9oX1fLjqSks5sfmjfgaJpZM4MVA0m
.

I solve this problem by adding
127.0.0.1 localhost in hosts
Thank you all.

I solved the problem by removing space in the project folder name.

Yeah, I solved that too as one of my folder has '&'.

But the weird part, I am still seeing this

///

/usr/bin/codesign --force --sign - --timestamp=none

/Users/eric/Documents/Codes/learn/reactnative/mySecondProject/ios/Build/Products/Debug-iphonesimulator/mySecondProject.app/PlugIns/mySecondProjectTests.xctest

* BUILD SUCCEEDED *

The following commands produced analyzer issues:
Analyze /Users/eric/Documents/Codes/learn/reactnative/mySecondProject/node_modules/react-native/ReactCommon/yoga/yoga/YGNodeList.c
Analyze /Users/eric/Documents/Codes/learn/reactnative/mySecondProject/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.c
(2 commands with analyzer issues)

Installing build/Build/Products/Debug-iphonesimulator/mySecondProject.app
An error was encountered processing the command
(domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier
build/Build/Products/Debug-iphonesimulator/mySecondProject.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

///

So run-ios will not work.

However it works if I run on xcode --> debug.

Just with many warnings as below

https://imgur.com/a/TyBGa

Any idea how to get run-ios working?

I am using this

Mac OS Sierra 10.12.6
Latest Xcode 8.3.3
node 8.4.0
npm 5.4.1
react native - tested both 0.47.2 and 0.48.2
react-native-cli - 2.0.1
yarn 0.20.0

I have also tried the following and won't worked

  • manually downloading all the files and stored into ~/.rncache
  • rm -rf npm_modules, then run "npm install"
  • react-native-git-upgrade
  • remove ios/build and run "react-native run-ios" again

Thanks.

On Wed, Sep 13, 2017 at 6:15 AM, rickcha notifications@github.com wrote:

I solved the problem by removing space in the project folder name.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/issues/12754#issuecomment-328999588,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AXIFs_Ggnia4CGYkzHHatteucW3uHsr8ks5shwKEgaJpZM4MVA0m
.

Adding localhost to NSAppTransportSecurity is worked for me.


NSExceptionDomains

localhost

NSExceptionAllowsInsecureHTTPLoads


yourapidomain.com

NSIncludesSubdomains

NSTemporaryExceptionAllowsInsecureHTTPLoads

NSAllowsLocalNetworking



The good ol "turn it off and on" trick worked for me.

Restarting the simulator (Hardware -> Restart) worked for me.

I have found the easiest/quickest way to bypass this is to exit the app within the simulator (2 x Cmd + Shift + H) and re-launch.

Thanks, yustada.
It really worked without any doubt.

If you are using REACT-NATIVE-ROUTER-FLUX version < 4.0.0

We upgraded to RN 0.47.2 and starting having this error. As suggested by @eemebarbe above, we deleted the react-native folder inside ~/node_modules/react-native-router-flux/node_modules and the error went away. We went as far as deleting the react folder at that same location. We did not have to add anything to the ATS Settings in the plist (we only have Allow Arbitrary Loads).

This also made a bunch of warnings (duplicate declarations) that the packager was throwing at launch

I got same error when run the project from xcode.
this is solved my issue:
info.plist → information Property List → + App Transport Security Settings → + Allow Arbitrary Loads = YES

Hi,

Issue: Gives me error when I try to run/install app in iPhone via Xcode. Works fine in simulator (Through Command line & Xcode)

Error:
img_0003

Xcode version: 8.3.3
Tested in iOS simulator: iPhone 6S - OS 10.3
Device: iPhone SE - OS 10.2.1
react-native: 0.45.1

Also I tried removing ios build from my project/ios folder.

Working fine for android ob both device and emulator.

Any Help. Thanks !!

Most of the cases this problem occurs when the DNS lookup / IP lookup fails to find localhost.

_Solution :_

Try adding the localhost ip to your etc host file
you can add the below lines to your etc host file (/etc/hosts)

127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

_## To confirm this is the issue_
you can hit the bundle url on safari (if you try it in chrome this will resolve but safari won't be able to resolve it). http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false

@vivekvijayakrishnan , My hosts file contains the above pair of address.

try
rm -rf ios/build/; react-native run-ios

I tried

rm -rf ios/build
react-native run-ios

and it fix my issue.

in my case watchman was the problem.
I reinstalled it and everything started working again

I ran into this problem too.
Seems that whenever I changed Info.plist this would get hit.
The only way to resolve it for me was to uncheck "run script only when installing" in build phases.
I had this checked because somewhere in react-native-xcode.sh it's hanging. (that's another problem I need resolve i guess)
So right now the only way to overcome this red screen is to

  • uncheck "run script only when installing"
  • run a build until it hangs
  • check "run script only when installing"
  • app will start properly

The below solution as mentioned in the above post heading worked for me:

  • Run "react-native run-ios"

  • When the error appears, run "npm install"

  • Then run "react-native run-ios" again.

For me, this issue may happen out of the proxy server I use. All I need is to bypass the localhost.

What fixed it for me: making the first letter of the name of the registered component capitalized. Totally mental. Just why? That's not the error that was reported.

None of the solutions above worked for me for the past several months. In other versions, I was able to change jsCodeLocation as follows:

jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];

But this doesn't work any more with the latest versions of react-native.

Anyway, this is THE reason I have since switched back to native Swift development on ios. I really enjoyed working with react-native when I was able to get it to work though.

I decided to re-init my project on the latest version of React Native (0.50.1 at the time) and it started working after I moved everything over from the old project.

I'm puzzled but at least I can continue now.

I found that the solution that @popstheman provided worked for me, using react-native 0.50.3. If I kill all my terminal windows and the simulator and then re run the build, the error comes back, but npm install and react-native run-ios fixes it again.

I init the project by create-react-native-app then npm run eject, so if I just run react-native run-ios will come this issue, so I just open xcode then run the project it will work fine.
reference from

You can run npm run eject to get a project very similar to what react-native init would generate. At that point you’ll need Xcode and/or Android Studio just as you would if you started with react-native init , adding libraries with react-native link will work, and you’ll have full control over the native code compilation process.
https://facebook.github.io/react-native/blog/2017/03/13/introducing-create-react-native-app.html

hope this will do a little help.

Was able to finally get this working. In newer versions of react-native (I just tested with v0.51.0), the jsCodeLocation hack in AppDelegate.m still works, but you have to use index.bundle instead of index.ios.bundle. So it should be like this (you would comment out the existing jsCodeLocation assignment and replace with the one below):

jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.bundle?platform=ios&dev=true"];

SOLUTION:

Do not forget to do react-native link if you use any library that needs that

The reason this fixes the problem is because ..ios/build ISN'T getting updated when we change project paths or simply when we change our project directory. There's no way the bundler will be able to track the changes so it sticks with the last known paths.

Don't overthink it, we already did. This however still needs to be automated by RN team.

I'm using IntelliJ to develop and in my case, for some reason IntelliJ stopped calling react-native start automatically before react-native run-ios every time I build my project, but if I run the project in Debug mode, then react-native start is called and everything works fine.

Now I need to figure out why react-native start is no longer called IntelliJ in Build mode.

I don;t know how but it's work, thanks
also people, search :common error in react native
it's helpful

@vegidio Did you make any headway and seeing why start isn't being called?

@NARUTOyuyang work for me, I used xxNet..... and open globalProxy option...

i closed global proxy option and then worked.

1.rm -rf ios/build
2.sudo vi /private/etc/hosts

 # Add this line
 127.0.0.1       localhost

works for me.

Add localhost to the AppTransportSecurity was my issue as well. Built for production and had to take it out, when I came back to work on it for got to put it back in.

<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>localhost</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict>

after upgrade to Xcode 9.2 i need to add below code snippet in the info.plist to fix this issue..

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>localhost</key>
        <dict>
            <key>NSExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
</dict>

@simplepanda In my case apparently it was a problem with IntelliJ. They had a bug related to React Native that was fixed in the latest version (2017.3.2) and it's working again after I updated.

My story: I had been using Xcode to build a React Native app for IOS for a few weeks (latest React Native, latest Xcode (9.2), on High Sierra), and everything was working great. All of a sudden, today, I got that dreaded "No bundle URL present".

I carefully read through all of the answers here. I tried a few things, but nothing really worked. Then I noticed, at the beginning of messages on the Xcode console, a message which said something like "bare http:// cannot be used...", and maybe something about Transport Security. Now, my app doesn't use any URL's (let alone an empty URL) so this was a bit puzzling. At any rate, I tried what Phil Andrews (and zjx) suggested: put in an exception for "localhost" under NSAppTransportSecurity in info.plist.

And it works! Why this worked without this before and now this is required, is truly a mystery!

Try to

npm install metro

Solved it because of a bug

If anyone wants a script for turning on/off the transport security in Info.plist:

    var fs = require('fs');
    var plist = require('plist');

    function modifyIosTransportSecurity(plistPath, enable) {
      var info = plist.parse(fs.readFileSync(plistPath, 'utf8'));
      info.NSAppTransportSecurity.NSAllowsArbitraryLoads = !enable;
      info.NSAppTransportSecurity.NSAllowsArbitraryLoadsInWebContent = !enable;
      info.NSAppTransportSecurity.NSAllowsLocalNetworking = !enable;
      fs.writeFileSync(plistPath, plist.build(info));
    }

I'm calling this from a pre- and post-build script that were added to XCode's build phases.

There are two apps(same project) on the simulator. Once I delete the new one, problem got resolved.

image

if you check this, Xcode cannot log some error ..uncheck it and find error
''undefined is not an object( evaluating '_reactNative.ViewPropTypes.style')''

and do like this:

1 import ViewPropTypes from react-native
2change View.propTypes to ViewPropTypes

and it work for me .
if you recently update your RN version ,you may have this .

i had this error only release mode. and dev mode work fine ..i have tried solutions nearly all above .but none works.

:
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

"react": "16.0.0-alpha.12",
"react-dom": "16.0.0-alpha.12",
"react-native": "0.51.0",

and a few days ago ,just update 0.44 to 0.51.0 . if this issues cant fixed. i will roll back to lower version have a try .

Not sure if this will help you guys but I changed my build config in Xcode (Product => Scheme => Edit Scheme) back to Debug and it worked.

This work for me:

react-native link
react-native run-ios

Based on this thread and some other there are a lot of errors causing this problem.
But mine was related with localhost domain. So make sure you have set 127.0.0.1 localhost in your /etc/hosts for Linux/Unix or equivalent file on Windows.

if your project opened by xcode. please close the xcode and run again, it works for me

Hi guys,
I solved it on my device by replacing on AppDelegate.m:

jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

By:

http://IP_ADDRESS_ON_MY_LAN:8081/index.ios.bundle?platform=ios&dev=true

Where IP_ADDRESS_ON_MY_LAN = 192.168....

I met the same issue after build release version(under ios).
I changed the followings and got normal result.
1)change AppDelegate.m codes:
comment
jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
and uncomment
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
2)re-enable ATS localhost in Info.plist
App Transport Security Settings -> Excepiton Domains -> localhost -> NSExceptionAllowsInsecureHTTPLoads -> TRUE
3)run react-native run-ios again and reload the app in simulator

@monkingame Thx, the localhost part saved my day!

@monkingame Thanks, the changing of comments worked for me. I have no idea what caused this error to start happening to begin with, started after I made the production build and wanted to back to debugging. How did that change the code location?

This work for me.

rm -rf ios/build
react-native run-ios

This work for me.

rm -rf ios/build/; kill $(lsof -t -i:8081);
react-native run-ios

run
yarn start or npm start
to start the development server

if necessary run again:
react-native run-ios

https://stackoverflow.com/a/48016926/4636856

For me for some reason the jsCodeLocation changed in AppDelegate.m

make sure it is
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

From another thread after trying everything, that solution worked:

"this is solved my issue:
info.plist → information Property List → + App Transport Security Settings → + Allow Arbitrary Loads = YES"

I got it resolved by including the below code in Info.plist file which I had removed from the production build.
<key>NSAppTransportSecurity</key> <dict> <key>NSExceptionDomains</key> <dict> <key>localhost</key> <dict> <key>NSExceptionAllowsInsecureHTTPLoads</key> <true/> </dict> </dict> </dict>

Easy boy, just remove ios/build (rm -rf ios/build) then run react-native run-ios again! Take me 30m to figure out...LOL...

@jiteshwadia same problem occurred to me.
what I have to do now??

For me, I was having a problem with Node not being recognized in any new tab opened. So I have to use nvm use in every new tab. Because the bundler was opening in a new tab when I ran npm run ios, it wasn't seeing Node. And I can't type in that bundler terminal for some reason.

So my solution was in one tab run nvm use 8.9.3 or whatever version you're on, then in that tab run npm start. Then open a new tab and do nvm use 8.9.3 and in that tab run npm run ios or however you run your simulator.

This work for me.

react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios' --assets-dest='./ios'

I had the same issue and after trying everything here qyvip's answer lead me to the right one.
In the ios>"Your Main Project Folder">AppDelegate.m .

update
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];

to be
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];

This worked for me. Check that your main.jsbundle is targeted to your main Project.
I also had to clean the caches.
image

Adding NSAllowsArbitraryLoads: true solved my problem.

Was this page helpful?
0 / 5 - 0 ratings