What is the meaning of 'No bundle URL present' in react-native?

IosReactjsReact Native

Ios Problem Overview


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.

enter image description here

Ios Solutions


Solution 1 - Ios

Solve the error No bundle URL present by:

  • Running the following command in your project root directory to delete the iOS build directory, and to kill other React Native sessions (assuming they're running on default port 8081) before re-building:

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

  • Update your React Native workflow to avoid these error occur by combining the above combination of commands into an alias and appending it to your Bash config file .bashrc with this command:

echo "alias rni=\"kill \$(lsof -t -i:8081); rm -rf ios/build/; react-native run-ios\"" >> ~/.bashrc; source ~/.bashrc

Now you can run React Native iOS build (without worrying about some of the common red error screens of death appearing) with a simple alias shortcut:

rni

Solution 2 - Ios

I just ran into this problem as well (first time getting started with React Native). The problem disappeared when - while an ios simulation(react-native run-ios) was running - I ran npm install and then react-native run-ios again. In the terminal window, it showed that it was bundling, and then the simulator showed the welcome screen.

Check this link for briefs after react-native init PropertyFinder line try to use npm start (This one works for me)

========================================================================

UPDATE for 16.9

My port 8081 was blocked by McAfee. Using a different port directly wasn't working react-native start --port=8082 and react-native run-ios --port=8082

Tried almost all solutions given here. but anything didn't work.

        "react": "16.9.0",
        "react-dom": "^16.12.0",
        "react-native": "0.61.5",

Solution:

Searched for 8081 in Xcode and replaced all of them with 8082. Then run the same commands to build and run the app. App works smoothly

react-native start --port=8082
react-native run-ios --port=8082

enter image description here

Solution 3 - Ios

This problem happens when you not allow unsecure connections via localhost, or maybe you tried to accept unsecure connections via http.

To fix this, add this on info.plist:

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

Solution 4 - Ios

Had same problem when I did bundle my app. Check that your main.jsbundle is targeted to your main Project

Solution 5 - Ios

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

Solution 6 - Ios

Close your simulator and the terminal. Open new one and go to your project, then upgrade your react-native like this:

react-native upgrade

Issue in: Infinite recursion in RCTFatal when the bundle fails to execute.

Solution 7 - Ios

Reason:

This is because the app cannot find out the server (which serves the UI - by javascript code).

Solution:

  • Make sure everything related to react native closed (not necessary, just to have clean start for my solution, after my explanation, you can figure out this is needed or not)
  • run npm run start or yarn start first
  • wait for this command done job (usually you will see Loading dependency graph, done.)
  • run react-native run-ios/android

Explanation:

  • React Native comes with 2 parts:

    • Native part
    • Javascript part
  • Build commands:

    • react-native run-ios/android is to build native part then deploy to devices and start app on devices (simulator/emulator/real device). This usually took 3~4 mins to finish.

    • npm run start or yarn start is to build the javascript part and start the dev server to serve the built UI to the app. This usually took 30 secs to finish.

=> Normally, the javascript part finished first then the native part came later. (based on time they used).

=> this is only true for the first time build (fresh build).

=> for re-build:

  • The native part just took 10~15 secs to check changes and because no change for native part => done before the javascript part was built and served. (I am not sure the javascript part was rebuilt or not but it took long time than native part)

  • So that is why we had this issue, the app ran and required thing that did not exist yet.

Bonus:

  • react-native run-ios/android will auto start the dev server for you.
  • That's why when you ran react-native run-ios/android right after react-native init <app_name>, everything ran well. (because auto start feature and the time was took for fresh build as state above).
  • Other "removing" solutions worked because they forced rebuilding.

Time used on this answer was relative to my machine => may different on others.

Solution 8 - Ios

Try running this code:

$ sudo xcodebuild -license

This may fix the issue. This works for me.

Solution 9 - Ios

following these steps:

  • open ios file project with xcode
  • in project bundle delete main.jsbundle file
  • add new empty file by main.jsbundle name
  • Run comment: react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
  • now react-native run-ios

youtube link: https://www.youtube.com/watch?v=eCs2GsWNkoo

Solution 10 - Ios

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.

Solution 11 - Ios

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 l . ocalhost

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

Solution 12 - Ios

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..)

Solution 13 - Ios

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.

Solution 14 - Ios

Solution --> npm start then open new Terminal and go to your project path and then hit react-native run-ios it works for me

Solution 15 - Ios

I had to run "react-native start" in a separate terminal. For some reason it wasn't running

Edit: Also, it turns out this was necessary because of a file permission not getting set properly. I am able to fix it by running the following command in an affected project directory.

chmod 777 node_modules/react-native/scripts/launchPackager.command

Solution 16 - Ios

What solved it for me:

  • Open a terminal window
  • cd into YOUR_PROJECT/ios
  • Remove the build folder with rm -r build
  • Run react-native run-ios again

Alternatively, you could open Finder, navigate to YOUR_PROJECT/ios and delete the build folder.

Then run react-native run-ios again.

Source: Andrew Bancroft

Solution 17 - Ios

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.

Solution 18 - Ios

first close the simulator, then run these on terminal

npm install

react-native run-ios

Solution 19 - Ios

This is an issue with react-native v0.42.1. Try to close all terminal and XCode instances and run:

launchctl unload ~/Library/LaunchAgents/com.github.facebook.watchman.plist
watchman version
react-native run-ios

Solution 20 - Ios

I had this same issue. But my problem was my Mac and iPhone were not in same wifi network.

So ensure that they are all in same network and rebuild once again. If this is not the case, try the solutions mentioned by other members here.

Solution 21 - Ios

check your network proxy , better shut it down.

or u should find an other way to maintain the packager server

Solution 22 - Ios

check your 'localhost' key at NSExceptionDomains dict in info.plist

if it doesn't exist, it causes error.

Solution 23 - Ios

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.

Solution 24 - Ios

I am running iOS simulator and this method works:

1. Clean your native project

1.a For Android project

cd android
gradlew clean

1.b For iOS project

cd ios
xcodebuild clean

2. Clean your reactnative cach

2.a If you are using npm

  npm start -- --reset-cache

2.b If you are using yarn

  yarn cache clean

After that you can run your project again.

Solution 25 - Ios

It has happened to me as well, after restarting my mac. There's a launchPackager terminal window opening up when you run your app on the simulator. I closed that window and terminated the process (I also cloosed the simulator), then run again react-native run-ios and everything works fine.

Solution 26 - Ios

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

Solution 27 - Ios

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.

Solution 28 - Ios

I tried all solutions above, didn't work for me. This is what worked for me, you can try this out if the answers above didn't work out for you.

  1. Open your project workspace on Xcode, and delete main.jsbundle file in [PROJECT-NAME]/main.jsbundle

  2. Create a new main.jsbundle, in that same folder. {right-click -> choose new file -> it'll open a dialog box, look for Others section, -> choose Empty -> name the file main.jsbundle -> save

  3. Then go back to the terminal of your project. And run this command:

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

  1. Start your packager and run the IOS app again

I do hope this helps you out.

Solution 29 - Ios

Assuming that you are using nvm and multiple versions of node installed, here is the solution:

  1. Say that you run npm install -g react-native-cli in node v6.9.5.
  2. Now make node v6.9.5 as default by running nvm alias default 6.9.5
  3. Now run react-native run-ios

The problem is, you have multiple versions of node installed via nvm and to install react-native-cli you have switched or installed latest version of node, which is not marked as default node to point in nvm yet. When you run react-native run-ios this opens up another new terminal window in which default nvm is not pointed to the node version where you have installed react-native-cli. Just follow the above setup, I hope that should help.

Solution 30 - Ios

make sure you have .jsbundle in your your project

Add

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

in your react native code try to reopen the project

Solution 31 - Ios

Step 1: Open the .xcodeworkspace project in your xcode by navigating it via "Terminal", "open /ios/.xcodeworkspace" Hit Enter.

Step 2: Delete the main.jsbundle file inside the folder you have

Step 3: Go back to VS Code, type this, react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

This generate you the new main.jsbundle file.

Step 4: react-native run-ios

you wont see the error again

Solution 32 - Ios

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:

- 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.

Solution 33 - Ios

another thing that working for me , is to open the project in xcode, and then clean and build it. usually it reruns the packaging server and solve the problem.

Solution 34 - Ios

Open a terminal window

cd into YOUR_PROJECT/ios

Remove the build folder with rm -r build

After that open your project in Xcode and run once. it will run with starting the server and create the main.jsbundle file.

Now if you Run react-native run-ios from terminal again it will work as expected.

Hope it will help!.

Solution 35 - Ios

Execute the below command:

killall -9 node
rm -rf ios/build
react-native run-ios

it will open launchpackager.command and the application will install on the ios simulator

Solution 36 - Ios

For Mcafee Macbook users :

sudo launchctl remove com.mcafee.agent.macmn

Solution 37 - Ios

Turn off/on wi-fi on device / on mac, rebuild app

For deeper debug: See XCode log, it may contain: "Could not connect to the server" with exact URL.

Solution 38 - Ios

Make sure launchPackage.command are running in a terminal and try run again. It will build the bundle. It is kinda like webpack-dev-server.

Solution 39 - Ios

  1. check your hosts that 127.0.0.1 localhost is not delete

  2. check that the network agent is not set up

  3. then npm install & react-native upgrade to reset your project

Solution 40 - Ios

It's because your client cannot reach your packager server.

If you are a Chinese Coder just as I am, I think you might using VPN get through the GFW. When your VPN tool is in 'Global Mode', all your request will travel through the world and cannot get localhost

Try 'Auto Proxy Mode'.

If you are not come from China, or your VPN setting is already 'Auto Proxy Mode', I suggest you shut down your packager server and try again.

Solution 41 - Ios

...another reason why this is happening is if you have installed Visual Studio Code React Native Tools but you keep trying to use react native in the terminal: it will work the first time but then it will stop and show you the red no bundle screen.

launching react native from vscode works perfectly instead...

Solution 42 - Ios

For my use case, i had to remove node_modules directory and run npm install.

$ rm -rf node_modules   (make sure you're in the ios project directory)
$ npm install

If you get error "dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.58.dylib", do the following:

$ brew uninstall --force node --ignore-dependencies node
$ brew uninstall icu4c --ignore-dependencies icu4c
$ brew install icu4c
$ brew unlink icu4c && brew link icu4c --force
$ brew install node

$ npm install

Solution 43 - Ios

try to add this :

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

Solution 44 - Ios

export FORCE_BUNDLING=true worked for me. There was a warning in the console that it was not getting bundled.

Solution 45 - Ios

I was connected to the network by cable and wifi on my macbook, disabled wifi and just hit run and it worked!

Solution 46 - Ios

We got around this by removing the SKIP_BUNDLING option in the build script that the RN docs suggested adding to speed up the debug build. The real fix (for our cause) is included in RN 0.57:

https://github.com/facebook/react-native/issues/20553

Solution 47 - Ios

This is how I did it:

  • Open a terminal window
  • cd into YOUR_PROJECT/ios
  • Remove the build folder with rm -r build
  • Run react-native run-ios again

Solution 48 - Ios

This problem may happen when we have multiple versions of node managed by nvm and default version is not intended version to run react-native. (make sure it is Node 8.3 or newer)

> react-native run-ios

opens a new terminal and runs the version of node found in the $PATH.

If it finds an older version of node not supported by react native, it may give this error.

Make sure, the $PATH variable is already pointing to intended version of node(make sure it is Node 8.3 or newer) when a new terminal is opened.

That solved the issue for me. Good luck.

Solution 49 - Ios

I've tried all solutions below, but nothing work:

  • sudo xcodebuild -license or
  • Remove the build folder with rm -r build and run react-native run-ios or
  • npm start and run react-native run-ios
  • Add NSAppTransportSecurity to `

I solved by do this:

  • Open host file sudo vi /private/etc/hosts (if you use VSCode, use this sudo code /private/etc/hosts)
  • Add three line if it's not exist
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
  • Run react-native run-ios again.

Solution 50 - Ios

Turn off global proxy (shadowsocks)

Solution 51 - Ios

This is because you probably have close the Metro Bundler Window or it might be crashed. just open another terminal/cmd in the project directory and run npm start. By Running npm start React Native will launch the MetroBundler Window once again. After bundler finishes the BUNDLE process, just reload the Application and you will be good to go.

Solution 52 - Ios

Ok, that may sound weird but none of those answers worked for me. I'm now at react-native 0.60 and the problem was happening on ios and android. the only solution that worked for me was running react-native run-ios or react-native run-android Then, when the error appears, run npm install (Keep the bundler and the simulator open) then run react-native run-ios or react-native run-android

Solution 53 - Ios

I faced the same issue and i resolved it by making changes in AppDelegate.m file. I changed

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

to

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

And it worked for me :)

Solution 54 - Ios

This problem occurred to me because Metro bundler started and received focus while I was typing on my keyboard in another window. My accidental input in the newly opened terminal window caused Metro bundler to crash. Rerunning react-native run-ios and waiting patiently fixed it.

Solution 55 - Ios

I tried most of answers above. But the only that works for is a watchman command(I use react-native: "0.60.4"):

watchman watch-del-all

Solution 56 - Ios

Maybe you forgot this step

cd ios && pod install

Solution 57 - Ios

For Ios follow the below steps,

  1. rm -rf ./node_modules
  2. npm install
  3. react-native link
  4. cd ios
  5. Pod Install
  6. cd..
  7. react-native start
  8. Build the app in XCode 1st time then you can also from VScode

Solution 58 - Ios

I had this screen as well, but my problem was that I had been using a proxy the night before (using Charles to monitor network requests from the RN env).

Once I shut off the proxy the app built/ran with no problems in my emulator.

Solution 59 - Ios

If, like me, you have a command set to be executed at startup in a terminal session (.bashrc/.bash_profile) that awaits for an input (in my case, the passphrase for an SSH Key with ssh-add), then you'll notice it actually prevents the opened Terminal to start the Metro server!

Try disabling that command at startup (or at least in the Terminal opened by React Native). It worked for me!

Solution 60 - Ios

Closing the currently running React Packager terminal window, and then re-running your iOS project from Xcode should work.

Solution 61 - Ios

Use the command

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

Solution 62 - Ios

If you are running IOS simulator make sure need to run this command

react-native run-android or npm run-android

once you running above command metro bundler will start , then run react-nagtive run-ios it will work .

Solution 63 - Ios

I know this question has many answers But these are not helped me. Below solution that helped me to resolve the error.

You have to go into your settings and allow this particular app.

  1. Open system preferences.
  2. Click 'security & privacy".
  3. Bottom right-click " Click the lock to make changes".
  4. Enter password.
  5. Under the general tab where it says ' app store and identified developers' you should see your blocked app.
  6. Final step: click "open anyway"

Source https://stackoverflow.com/questions/58516286/launchpackager-command-cannot-be-opened-because-it-is-from-an-unidentified-dev

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionYingch XueView Question on Stackoverflow
Solution 1 - IosLuke SchoenView Answer on Stackoverflow
Solution 2 - IosSkip SuvaView Answer on Stackoverflow
Solution 3 - IosWitaloBenicioView Answer on Stackoverflow
Solution 4 - IosparseView Answer on Stackoverflow
Solution 5 - IoscwRichardKimView Answer on Stackoverflow
Solution 6 - IosMateo MarconiView Answer on Stackoverflow
Solution 7 - IosKhoaView Answer on Stackoverflow
Solution 8 - IosKusal KithmalView Answer on Stackoverflow
Solution 9 - IosHamed KharazmiView Answer on Stackoverflow
Solution 10 - IossonlexqtView Answer on Stackoverflow
Solution 11 - IosVivekView Answer on Stackoverflow
Solution 12 - IosSerdar D.View Answer on Stackoverflow
Solution 13 - IosurbancvekView Answer on Stackoverflow
Solution 14 - Iosrahul.sapkal23View Answer on Stackoverflow
Solution 15 - IosSeanMCView Answer on Stackoverflow
Solution 16 - Iosl3aronsansglandView Answer on Stackoverflow
Solution 17 - IosPrakash salawriaView Answer on Stackoverflow
Solution 18 - IosPramodya AbeysingheView Answer on Stackoverflow
Solution 19 - IosShobhit SharmaView Answer on Stackoverflow
Solution 20 - IosAbraham JagadeeshView Answer on Stackoverflow
Solution 21 - Iosuser1684758View Answer on Stackoverflow
Solution 22 - IosogelacinycView Answer on Stackoverflow
Solution 23 - IosToby FlemmingView Answer on Stackoverflow
Solution 24 - Iosazwar_akbarView Answer on Stackoverflow
Solution 25 - IosgianniView Answer on Stackoverflow
Solution 26 - IosGrzegorz PawlikView Answer on Stackoverflow
Solution 27 - IosChrisView Answer on Stackoverflow
Solution 28 - IosAnayo OleruView Answer on Stackoverflow
Solution 29 - IosSyedView Answer on Stackoverflow
Solution 30 - IosSaloni ParikhView Answer on Stackoverflow
Solution 31 - IosPreetham Kumar PView Answer on Stackoverflow
Solution 32 - IosBruce LeeView Answer on Stackoverflow
Solution 33 - IosEliran GoshenView Answer on Stackoverflow
Solution 34 - IosvikramView Answer on Stackoverflow
Solution 35 - IosSaif SiddiquiView Answer on Stackoverflow
Solution 36 - IosShubhamView Answer on Stackoverflow
Solution 37 - IosDaniel GarmoshkaView Answer on Stackoverflow
Solution 38 - IosCodlerView Answer on Stackoverflow
Solution 39 - IosJaneView Answer on Stackoverflow
Solution 40 - IosJared ChenView Answer on Stackoverflow
Solution 41 - IosEdoardoView Answer on Stackoverflow
Solution 42 - IosHau LeView Answer on Stackoverflow
Solution 43 - IosThe DninoView Answer on Stackoverflow
Solution 44 - IosTechmaddyView Answer on Stackoverflow
Solution 45 - IosWiRaView Answer on Stackoverflow
Solution 46 - IosmphView Answer on Stackoverflow
Solution 47 - IoshonorView Answer on Stackoverflow
Solution 48 - IosArun KandregulaView Answer on Stackoverflow
Solution 49 - IosTien LXView Answer on Stackoverflow
Solution 50 - IosynceonrudiView Answer on Stackoverflow
Solution 51 - IosKiran ManiyaView Answer on Stackoverflow
Solution 52 - IosAlcides BezerraView Answer on Stackoverflow
Solution 53 - IosWaleed NaveedView Answer on Stackoverflow
Solution 54 - IosschmijosView Answer on Stackoverflow
Solution 55 - IosO. BorcuhinView Answer on Stackoverflow
Solution 56 - IossuperupView Answer on Stackoverflow
Solution 57 - IosSandeep RajbharView Answer on Stackoverflow
Solution 58 - IosKyle BennettView Answer on Stackoverflow
Solution 59 - Iosm0rganView Answer on Stackoverflow
Solution 60 - Iosa_rahmanshahView Answer on Stackoverflow
Solution 61 - IosDivye ShahView Answer on Stackoverflow
Solution 62 - Ioskallayya HiremathView Answer on Stackoverflow
Solution 63 - IosRamView Answer on Stackoverflow