9

I get the following error when trying to do react-native run-ios (see screenshot below). I have checked this answer as well as the github thread but neither were helpful.

Any ideas on what to look at or how to make this work? The problem seems to be isolated to ios, as the android emulator works ok. Looks like maybe it's some sort of bug with the facebook code.

enter image description here

Community
  • 1
  • 1
dcp
  • 54,410
  • 22
  • 144
  • 164
  • 3
    Possible duplicate of [What means of no bundle URL present in react-native?](http://stackoverflow.com/questions/42610070/what-means-of-no-bundle-url-present-in-react-native) – Moussawi7 Mar 22 '17 at 13:29
  • 1
    @Moussawi7 - Yes, I mentioned in my question that I had already checked that and it wasn't helpful. – dcp Mar 22 '17 at 13:34
  • 1
    Try using ` jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"]; ` in your Appdelegate.m instead of your current **jsCodeLocation** value use your ip and port – Hariks Mar 29 '17 at 07:29
  • 1
    @Hariks - Thanks for your suggestion. It made no difference as I still got the same error. – dcp Mar 29 '17 at 12:23
  • 1
    I was able to reproduce the issue when I removed the jsCodeLocation from Appdelegate.m. Do share your Appdelegate.m file, I guess the issue is there – Hariks Mar 29 '17 at 13:40
  • Have you found a solution? I am also struggling with this, none of the mentioned threads help me out. – skywlkr Apr 06 '17 at 08:24
  • @skywlkr - I have not found a solution. None of the threads helped me either, and the latest version of react-native (v0.43) does not solve the problem. I still get the "No bundle URL present". – dcp Apr 06 '17 at 11:09

8 Answers8

10

For those still interested i resolved this just by running

react-native start

which starts the packager in the current terminal window and run in other terminal window

react-native run-ios
Jayffe
  • 1,269
  • 9
  • 13
7

I resolved it with the following solution:

Edit <your_project_folder>/ios/<project_name>/AppDelegate.m and change the jsCodeLocation variable as follows:

jsCodeLocation =
    [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];
dcp
  • 54,410
  • 22
  • 144
  • 164
  • 1
    I've tried a dozen suggestions and this is the one that fixed it for me, thanks! Just a note: remember to keep the original line commented, you may need that one for production builds. – Jk041 Nov 14 '17 at 13:59
  • This solution looks pretty hacky. I'd first check if you have `127.0.0.1 localhost` in your hosts file, then clean the project and retry. – Mokkun Sep 05 '18 at 06:03
4

Your issue is that the file main.js bundle part of iOS is not generated all the times or sometimes is generated, but wrong. To solve the issue, follow these steps:

  1. Add the following line inside the scripts of the package.json

    "build:ios": "react-native bundle --entry-file='index.js' --bundle-output='./ios/main.jsbundle' --dev=false --platform='ios'"

  2. Then run following command:

    yarn build:ios or npm run build:ios

  3. Open Xcode, select "project", then click the project name; go to the "build phases", then click on "copy build resources" as your main.js bundle there

  4. Run the react-native run-ios

This works for me

Daemon Painter
  • 3,208
  • 3
  • 29
  • 44
3

This happens to me when I work on the same react-native project on different computers. Closing the simulator and deleting the ios > build folder followed by running react-native run-ios again solves it for me.

maesk
  • 186
  • 3
  • 13
  • This answer solved a problem for me. As author mentioned, my case is that I use two computers for same project – M.D Jun 01 '17 at 13:43
1

Try this after the simulator is already running:

npm install

react-native run-ios

RainCast
  • 4,134
  • 7
  • 33
  • 47
  • 1
    Made no difference, still get same error about the bundle. – dcp Mar 29 '17 at 12:54
  • 3
    This worked for me with a react native app built using the [getting started](https://facebook.github.io/react-native/docs/getting-started.html) instructions. Then, if I run my app using `react-native run-ios`, wait for the packager window to load its dependency graph, then go back to the terminal window where I ran the `run-ios` command, do an `npm install` and then re-run `run-ios`, I can run my app. But I have to do this each time I stop and start the packager / run-ios. – mheavers Apr 05 '17 at 18:46
  • 1
    @mheavers - I just tried it again with latest react-native version, and it still does not work. – dcp Apr 06 '17 at 11:30
  • 1
    Hmmm - it also worked for me if I deleted the build folder, which obviously isn't a good long term solution, but got things running so that I could test. Regardless, looking forward to Facebook fixing the issue. – mheavers Apr 07 '17 at 15:22
1

I also got this error when developing. Try this solution in the simulator:

  1. Hold down shift + cmd + H twice to bring up running apps

  2. Then swipe up on your the app you would like to get rid of.

  3. Click on your app.

This worked for me, after looking through countless solutions this was all I actually needed to do! Hope this helps.

Ega
  • 437
  • 4
  • 12
1

For me, I did not have watchman installed. To check if you have it installed, from your terminal you can run brew list. If you do not see watchman listed, simply run brew install watchman.

NOTE: If you get this error during installation:

Error: Xcode alone is not sufficient on Sierra.
Install the Command Line Tools:
  xcode-select --install

You need to install the Xcode Command Line Tools. So, from your terminal run xcode-select --install. After installation of the tools is complete, you will need to re-run brew install watchman. Then you should be able to start your project by running react-native run-ios.

David
  • 652
  • 2
  • 12
  • 21
0

.. I faced the same issue. simulator was showing No Bundle Url present make sure you are running a packager server ..... and terminal showed me the error of watcherman of which I attached with this answer. what I did? I only ran the following both commands one by by in project directory and then ran npx run-ios and the error solved. note that it is not the problem of a specific app. i faces the issue even if i was running another app. so dont make changes in your porject app.

brew reinstall watchman
watchman watch-del-all
watchman shutdown-server