facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.09k stars 24.19k forks source link

RN 0.60.5 iOS release build "No bundle URL present" after updating #26331

Open rnnyrk opened 5 years ago

rnnyrk commented 5 years ago

I've just updated my project from React Native 0.59.9 to 0.60.5 with react-native upgrade and the update helper mentioned in the official blog post. Although my project is already a little "complex" because it's using some libraries etc. it seemed the update was successful.

But unfortunately my app won't work with the Test - Release scheme anymore. On the debug scheme it works without any problems. The release also reaches the "Build succeeded" status, but as soon the app launches it's stuck because of the "No bundle URL present" error (see also my attached Xcode screenshot).

I've tried everything I could find on the internet so far. Re-installing the NPM dependencies and Pods; removing the build folder, changing the NSAppTransportSecurity in the Info.plist, but it won't resolve the issue.. The deployed app via TestFlight breaks as well on startup.

React Native version:

System: OS: macOS 10.14.6 CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz Memory: 430.30 MB / 8.00 GB Shell: 5.3 - /bin/zsh Binaries: Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node Yarn: 1.10.1 - /usr/local/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3 Android SDK: API Levels: 23, 26, 28, 29 Build Tools: 28.0.3, 29.0.0 System Images: android-29 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.4 AI-183.6156.11.34.5522156 Xcode: 10.3/10G8 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.60.5 => 0.60.5 npmGlobalPackages: react-native-cli: 2.0.1

Steps To Reproduce

  1. Update react-native from 0.59.9 to 0.60.5
  2. Remove node_modules, ios/Pods, ios/build and Podfile.lock
  3. Re-install node_modules and run pod install
  4. Open Project.xcworkspace
  5. Select the scheme "Project - Test" go to "Edit scheme > Run > Build Configuration" and change the scheme to "Test - Release"
  6. Build the project (on device or simulator, doesn't matter)
  7. "Build succeeded" and app starts
  8. App is stuck on splash screen and Xcode shows the error as in the attached screenshot

Files / Code

Currently these are my Info.plist, Podfile and package.json:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>Jobner</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>2</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>localhost</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIViewControllerBasedStatusBarAppearance</key>
    <false/>
    <key>UIStatusBarHidden</key>
    <true/>
    <key>ITSAppUsesNonExemptEncryption</key>
    <false/>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>Your location is required for searching jobs near you</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>Your location is required for searching jobs near you</string>
  <key>LSApplicationQueriesSchemes</key>
  <array>
    <string>whatsapp</string>
  </array>
</dict>
</plist>
platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

project 'Project',
  'Prod - Debug' => :debug,
  'Acc - Debug' => :debug,
  'Test - Debug' => :debug,
  'Prod - Release' => :release,
  'Acc - Release' => :release,
  'Test - Release' => :release

target 'Project' do
  # Pods for Project
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/React'
  pod 'React-DevSupport', :path => '../node_modules/react-native/React'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  target 'ProjectTests' do
    inherit! :search_paths
    # Pods for testing
  end

  use_native_modules!
end
{
  "name": "project",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "react-native start",
    "lint": "eslint --ext .jsx --ext .js src/",
    "ios": "react-native run-ios --scheme \"Project - Test\" --configuration \"Test - Debug\"",
    "android": "ENVFILE=.env.dev react-native run-android --variant=devDebug --appIdSuffix=dev",
    "postinstall": "npx jetify"
  },
  "dependencies": {
    "@aws-amplify/auth": "1.2.31",
    "@aws-amplify/core": "1.1.0",
    "@babel/polyfill": "7.4.4",
    "@react-native-community/async-storage": "1.6.1",
    "accounting": "0.4.1",
    "amazon-cognito-identity-js": "3.0.15",
    "cross-fetch": "3.0.4",
    "dayjs": "1.8.15",
    "iban": "0.0.12",
    "prop-types": "15.7.2",
    "qs": "6.7.0",
    "react": "16.9.0",
    "react-geocode": "0.1.2",
    "react-native": "0.60.5",
    "react-native-android-keyboard-adjust": "^1.2.0",
    "react-native-bootsplash": "1.0.1",
    "react-native-config": "luggit/react-native-config#master",
    "react-native-datepicker": "1.7.2",
    "react-native-device-info": "2.3.2",
    "react-native-gesture-handler": "1.3.0",
    "react-native-keyboard-aware-scroll-view": "0.9.1",
    "react-native-keyboard-spacer": "^0.4.1",
    "react-native-linear-gradient": "2.5.6",
    "react-native-pdf": "5.1.4",
    "react-native-svg": "9.8.4",
    "react-navigation": "3.11.0",
    "react-redux": "7.1.1",
    "redux": "4.0.4",
    "redux-devtools-extension": "2.13.8",
    "redux-thunk": "2.3.0",
    "reselect": "^4.0.0",
    "rn-fetch-blob": "0.10.16",
    "styled-components": "4.3.2"
  },
  "devDependencies": {
    "@babel/core": "7.5.5",
    "@babel/plugin-proposal-export-default-from": "7.5.2",
    "@babel/plugin-proposal-export-namespace-from": "7.5.2",
    "@babel/plugin-syntax-dynamic-import": "7.2.0",
    "@babel/runtime": "7.5.5",
    "babel-eslint": "10.0.2",
    "babel-plugin-module-resolver": "3.2.0",
    "babel-plugin-styled-components": "1.10.6",
    "eslint": "^5.16.0",
    "eslint-config-react-app": "^4.0.1",
    "eslint-import-resolver-babel-module": "5.1.0",
    "eslint-plugin-flowtype": "3.13.0",
    "eslint-plugin-import": "2.18.2",
    "eslint-plugin-jsx-a11y": "^6.2.1",
    "eslint-plugin-react": "7.14.3",
    "eslint-plugin-react-hooks": "1.6.1",
    "eslint-plugin-react-native": "3.7.0",
    "jetifier": "^1.6.4",
    "metro-react-native-babel-preset": "0.56.0"
  },
  "xcodeSchemes": {
    "Debug": [
      "Test - Debug",
      "Acc - Debug",
      "Prod - Debug"
    ],
    "Release": [
      "Test - Release",
      "Acc - Release",
      "Prod - Release"
    ],
    "projectDirectory": "ios",
    "settings": {}
  },
  "rnpm": {
    "assets": [
      "./src/app/static/fonts/"
    ]
  }
}

The AppDelegate.m should link to the correct bundle file right? This code is in there:


- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
#if DEBUG
  return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
#else
  return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
#endif
}
Screenshot 2019-09-04 at 20 44 20
rnnyrk commented 5 years ago

I've found a solution in this Stack Overflow post. Following these steps you can create a main.jsbundle and assets folder and add it to your project.

  1. Run the following command: react-native bundle --dev false --platform ios --entry-file index.js --bundle-output ios/main.jsbundle --assets-dest ./ios
  2. Add main.jsbundle and assets directory to Xcode by dragging them in your project.

Although this feels like a temporary solution.. I've got two main.jsbundle files right now. Can I delete the one in my project folder? And the assets folder includes some node modules do I have this command every time I add new modules and manually drag the assets in my project root?

Also when I build it via CI/CD (Bitrise) there is no main.jsbundle created in the root since it is ignored by default in .gitignore. So my TestFlight builds are still failing. How to handle this?

What exactly is happening here?

Screenshot 2019-09-05 at 09 46 52
rnnyrk commented 5 years ago

Resolved the issue. Seemed like my project was missing a shell script to automatically build the bundle and assets under "Build Phases > Bundle React Native code and images". Also Xcode was crashing when I opened this section.

I opened the file /ios/Project.xcodeproj/project.pbxproj, searched for this part:

/* Begin PBXShellScriptBuildPhase section */
        00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
            isa = PBXShellScriptBuildPhase;
            buildActionMask = 2147483647;
            files = (
            );
            inputPaths = (
            );
            name = "Bundle React Native code and images";
            outputPaths = (
            );
            runOnlyForDeploymentPostprocessing = 0;
            shellPath = /bin/sh;
        };

and added the shell script, so I ended up with:

/* Begin PBXShellScriptBuildPhase section */
        00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
            isa = PBXShellScriptBuildPhase;
            buildActionMask = 2147483647;
            files = (
            );
            inputPaths = (
            );
            name = "Bundle React Native code and images";
            outputPaths = (
            );
            runOnlyForDeploymentPostprocessing = 0;
            shellPath = /bin/sh;
            shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
        };

Hopefully this prevents others to spend 2 days on this ;)

arthurstockler commented 4 years ago

there is already this line in my file, however, when running use of my device or error continues. He is only working on the emulator

eggybot commented 4 years ago

got this issue coming from RN0.60.5 to RN0.61.1, I experience so many issue upgrading to the latest version. Then the only issue I'm facing now is this one. The Metro bundle was not initiating and I need to manually run "react-native start" which is not good. I hope someone can find solution for this issue.

ivanguimam commented 4 years ago

same problem to update 0.59.9 to 0.61.1

ivannovazzi commented 4 years ago

same here

samuthekid commented 4 years ago

+1

Andriiklymiuk commented 4 years ago

same problem here

franckboudraa commented 4 years ago

Same issue for me.

2019-10-07 17:56:49.686 [fatal][tid:main] No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
2019-10-07 17:56:49.692042+0200 SesameApp[3795:761740] No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.
2019-10-07 17:56:49.693555+0200 SesameApp[3795:761740] *** Terminating app due to uncaught exception 'RCTFatalException: No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.', reason: 'No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.'
*** First throw call stack:
(0x1ee34298c 0x1ed51b9f8 0x1000dc79c 0x1000f3c6c 0x1edd80a38 0x1edd817d4 0x1edd2f008 0x1ee2d432c 0x1ee2cf264 0x1ee2ce7c0 0x1f04cf79c 0x21ad99c38 0x1000c1f98 0x1edd928e0)
libc++abi.dylib: terminating with uncaught exception of type NSException
franckboudraa commented 4 years ago

Resolved the issue. Seemed like my project was missing a shell script to automatically build the bundle and assets under "Build Phases > Bundle React Native code and images". Also Xcode was crashing when I opened this section.

I opened the file /ios/Project.xcodeproj/project.pbxproj, searched for this part:

/* Begin PBXShellScriptBuildPhase section */
      00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
          isa = PBXShellScriptBuildPhase;
          buildActionMask = 2147483647;
          files = (
          );
          inputPaths = (
          );
          name = "Bundle React Native code and images";
          outputPaths = (
          );
          runOnlyForDeploymentPostprocessing = 0;
          shellPath = /bin/sh;
      };

and added the shell script, so I ended up with:

/* Begin PBXShellScriptBuildPhase section */
      00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
          isa = PBXShellScriptBuildPhase;
          buildActionMask = 2147483647;
          files = (
          );
          inputPaths = (
          );
          name = "Bundle React Native code and images";
          outputPaths = (
          );
          runOnlyForDeploymentPostprocessing = 0;
          shellPath = /bin/sh;
          shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
      };

Hopefully this prevents others to spend 2 days on this ;)

I downgraded to Xcode 10.3 and applied that, it's working now thank you.

ergunyasar commented 4 years ago

It happened to me as well when I upgraded react-native from '0.59.9' to '0.61.2'. For anyone still experiencing this, after the upgrade please check if there is a build phase in xcode called Start packager. If not click the + sign and choose 'new run script phase'. You will see a new phase called 'Run script' added to the bottom of the build phases. Add this shell script code

export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}" echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react-native/scripts/.packager.env" if [ -z "${RCT_NO_LAUNCH_PACKAGER+xxx}" ] ; then if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then echo "Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly" exit 2 fi else open "$SRCROOT/../node_modules/react-native/scripts/launchPackager.command" || echo "Can't start packager automatically" fi fi

Change its name to 'Start packager' and move it to the between 'Check Pods Manifest.lock' and 'Compile sources'. I hope it helps.

NirvaleO commented 4 years ago

I'm having the same issue. I open my bundler manually and even though it seems like the app can't reach it even though NSAppTraspotSecurity is correct. Anyone has found solutions for this?

davidmarinangeli commented 4 years ago

Same for me, @ergunyasar your solution doesn't work. It gives me an error during build.

rnnyrk commented 4 years ago

I re-opened this issue since a lot of people seem to have encounter the same error with assumedly another solution.

davidmarinangeli commented 4 years ago

The script that I have found in another issue and that is working for me is the following:

export RCT_METRO_PORT="${RCT_METRO_PORT:=8081}"
echo "export RCT_METRO_PORT=${RCT_METRO_PORT}" > "${SRCROOT}/../node_modules/react-native/scripts/.packager.env"
if [ -z "${RCT_NO_LAUNCH_PACKAGER+xxx}" ] ; then
if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then
if ! curl -s "http://localhost:${RCT_METRO_PORT}/status" | grep -q "packager-status:running" ; then
echo "Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly"
exit 2
fi
else
open "$SRCROOT/../node_modules/react-native/scripts/launchPackager.command" || echo "Can't start packager automatically"
fi
fi

All the steps are pretty much the same that @ergunyasar wrote: the only thing that changes is the script code above.

RN 0.61.3

CooperCodeComposer commented 4 years ago

Yes! Thx a lot @davidmarinangeli and @ergunyasar adding the script (David edition) worked for me (after trying a bunch of the other solutions out there).

francisl commented 4 years ago

I was trying to go through the official "Getting Started" and I faced the same issue following all the steps. The expo "Getting started" steps are working though.

Setup:

First error (default port)

First, when I keep the default port, it will crash with a port in use error: (Note that there is nothing listening on that port. lsof -t -i:8081 return nothing

npx react-native run-ios

Port 8081 already in use, packager is either not running or not running correctly
Command PhaseScriptExecution failed with a nonzero exit code

** BUILD FAILED **

The following build commands failed:
    PhaseScriptExecution Start\ Packager /AwesomeTSProject2/ios/build/AwesomeTSProject2/Build/Intermediates.noindex/AwesomeTSProject2.build/Debug-iphonesimulator/AwesomeTSProject2.build/Script-FD10A7F022414F080027D42C.sh
(1 failure)

Second Error with custom port (no bundle error)

Then if I change the port npx react-native run-ios --port 9092

I got the same error as describe here

no bundle url present

@rnnyrk solution works fine as long as I keep specifying a custom port.

When I use the default, I got the first error even after the fix.

NetPumi2 commented 4 years ago

I use @davidbiedenbach solution and i had to combinate it with this solution: https://stackoverflow.com/a/54230598/2360269

jeffminsungkim commented 4 years ago

@eggybot Are you using iterm2 or integrated terminal in VS Code? If so, run react-native run-ios command from a default terminal. For me, it solved the issue. I couldn't believe how I spent a few hours on this.

shixiaoquan commented 4 years ago

@rnnyrk @arthurstockler @eggybot @ivanguimam @ivannovazzi
this video saved me , I have tried https://www.youtube.com/watch?v=eCs2GsWNkoo

LeonaYoung commented 4 years ago

It happened to me as well when I upgraded react-native from '0.59.9' to '0.61.2'. For anyone still experiencing this, after the upgrade please check if there is a build phase in xcode called Start packager. If not click the + sign and choose 'new run script phase'. You will see a new phase called 'Run script' added to the bottom of the build phases. Add this shell script code

where is the + sign? @ergunyasar

vj-raghavan commented 4 years ago

All,

I am on the latest version of react-native cli and react-native, react-native-cli: 2.0.1 react-native: 0.61.5 I am trying to initialise a brand new project and run it in the iOS simulator and have run into this issue consistently no matter what I try , i. e create a new project, remove the build directory in iOS and try running it.

However the video suggestion did work but it had a lot of unnecessary side effects like losing hot reloading etc.

Is there a fix available for this issue ? if downgrading is an option I am happy to downgrade the cli and react-native versions.

Thanks in advance for any help.

Rutvik17 commented 4 years ago

I am upgrading from react native 0.59.10 to 0.60.6 and i am facing this issue, i have tried all the solutions/suggestions posted in this thread. But no luck 😞 If anyone has found a solution please help.

vj-raghavan commented 4 years ago

All,

I am on the latest version of react-native cli and react-native, react-native-cli: 2.0.1 react-native: 0.61.5 I am trying to initialise a brand new project and run it in the iOS simulator and have run into this issue consistently no matter what I try , i. e create a new project, remove the build directory in iOS and try running it.

However the video suggestion did work but it had a lot of unnecessary side effects like losing hot reloading etc.

Is there a fix available for this issue ? if downgrading is an option I am happy to downgrade the cli and react-native versions.

Thanks in advance for any help.

Okay, Here is what happened now. I created a new project and initialised it as per usual and it worked. I used npx react-native run-ios and it seems to have worked without any issues.. Previously I was using react-native run-ios. Which I reckon may have used a older version of react-native hanging around somewhere in my refs.

shixiaoquan commented 4 years ago

I am upgrading from react native 0.59.10 to 0.60.6 and i am facing this issue, i have tried all the solutions/suggestions posted in this thread. But no luck If anyone has found a solution please help.

I upgrade xcode to the lasted version, it worked

alixq commented 4 years ago

If none of these have worked, my issue was with the packager (responsible for the bundle) build phase disappearing.

Check out the solution for the packager problem here: https://github.com/facebook/react-native/issues/25585

Also, make sure react-native-cli doesn't call an old globally-installed version and instead the one installed in your project by react-native. Run npm uninstall -g react-native-cli and use yarn commands to use react-native-cli.

diazevedo commented 4 years ago

Hi there, I got the same error starting a new project at 0.61.5. I deleted the ios/build folder and re-run the react-native run-ios.

It worked for me.

Thanks

olczake commented 4 years ago

What worked for me is a combination of the solutions that have been posted.

  1. Delete ios/build folder
  2. Run react-native start (to manually launch the bundler)
  3. Open new tab and run react-native run-ios

This worked for me.

nickarora commented 4 years ago

I encountered this error during a 0.60+ upgrade, even when I can verify that the metro bundler is running on port 8081. It seems that react-native is failing to detect the existence of a running server on that port -- or perhaps its looking for a different port altogether? using the --port flag has no benefit. deleting ios/build and reinstalling dependencies has no effect

Davidster commented 4 years ago

I had a similar issue in which the package was indeed running as I started it manually yet the app was still complaining with the "No bundle URL present" error screen on react-native@0.61.5 I noticed in the logs of xcode that something was trying to access port 8083:

Task <>.<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x600002d86550 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=http://localhost:8083/status, NSErrorFailingURLKey=http://localhost:8083/status, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}

So I (naively) tried running the packager on that same port, 8083, then reloaded the app in the simulator and it magically worked:

npx react-native start --port 8083

Hope this helps at least one poor(t) soul out there in the wild 🚀

tusharpandey commented 4 years ago

I encountered this error during a 0.60+ upgrade, even when I can verify that the metro bundler is running on port 8081. It seems that react-native is failing to detect the existence of a running server on that port -- or perhaps its looking for a different port altogether? using the --port flag has no benefit. deleting ios/build and reinstalling dependencies has no effect

hi nick, have you found solution ?

tusharpandey commented 4 years ago

same problem to update 0.59.9 to 0.61.1

same in 0.61.5.

nickarora commented 4 years ago

I overcame this by creating a brand new react-native app with RN 0.61.5, then laboriously porting our existing app over. It wasn't pleasant, but it worked. Attempting to upgrade our existing app to 0.61.5 led us to encounter too many road-blocks (like this one)

tusharpandey commented 4 years ago

I am still facing it, actually using main.jsbunlde file works fine but as pre-bundled file , I have to make bundle file each time to reflect changes so I don't think its a solution...

and using mace:8081 in appdegate.m giving me 401-authentication error.

Kureev commented 4 years ago

Let me shed some light on the "No Bundle URL present" mystery.

Your React Native application knows where the bundler server is by a neat script called react-native-xcode.sh which runs a few commands to determine your machine's IP address and write it to the ip.txt file that can be later read by your app (as it will be bundled in the app along with the other files). What might happen here is that for some reason you don't run the script when building your apps.

For example: you work on two machines and have a "Run script only when installing" checkbox checked for "Bundle React Native code and images". In this case, you might install your app on the device using machine A and then, in the evening, try to run it with machine B. That won't work, because this script won't be re-triggered and hence, your application bundler IP address will keep pointing to the machine A. In order to solve this, you'll have to either remove the app from your phone and re-install again or uncheck the checkbox.

Hope this helps ✌️

hryjosn commented 4 years ago

For me, the reason is that I didn't rollback the code in AppDelegate.m after I build the release version below

`- (NSURL )sourceURLForBridge:(RCTBridge )bridge {

if DEBUG

return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; // return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

else

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

endif

}

@end `

wjcwukong commented 4 years ago

@rnnyrk @arthurstockler @eggybot @ivanguimam @ivannovazzi this video saved me , I have tried https://www.youtube.com/watch?v=eCs2GsWNkoo

save my day, thanks a lot!

MianJawadAhmad commented 4 years ago

https://powercoder23.wordpress.com/2017/10/29/solved-no-bundle-url-present/

this link save my life after 3 days I fixed this error

ali-pedram commented 4 years ago

And sometime this error is due to your device and computer not being on the same network.

jjmiranda commented 4 years ago

I resolved the problem putting my device and computer in the same network :)

malord commented 4 years ago

I had this because the IP address I need to use is on en5 and react-native-xcode.sh only checks en0 and en1 before grepping ifconfig for the first inet address (which in my case was an IP address created by Parallels). It first happened to me on an older project that used to work fine, so didn't seem to be related to React Native itself but to my Mac setup.

I created a PR to check en0..en8 rather than just en0 and en1: https://github.com/facebook/react-native/pull/28764

EdgardoRodriguezSolano commented 4 years ago

What worked for me is a combination of the solutions that have been posted.

  1. Delete ios/build folder
  2. Run react-native start (to manually launch the bundler)
  3. Open new tab and run react-native run-ios

This worked for me.

This one worked for me. I didn't delete the ios/build folder. Instead I used a regular terminal and not iTerm2.

estebanr92 commented 4 years ago

This error occurred to me because I was using NVM and I replaced de Node binary path in Build phases -> Bundle React Native code and images with "which node" path. Everything worked fine with the simulator but not while running on device or testflight build . To solve this I re-installed Node with the oficial package installer and returned Node binary path to its original value. Hope this helps.

MianJawadAhmad commented 4 years ago

Many people have this issue recently and asking about this “No bundle URL present” error and I just faced it myself.

I got this error when I updated my react-native version, different people got this issue for a different reason, some are not sure what they changed

Even still, 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 just delete my node_module, then npm install and it works. But it is a little worrying that it happens so randomly.

The most common fix that worked for the majority of the people is

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

If still, it doesn’t work, I have collected some solutions that worked for different conditions

Let's start with some basic troubleshooting

While the simulator is running don’t close your bundler. Go to the path and run npm install then again

react-native run-ios Clean up your code, Clean the project directory, Removing the node_modules and do npm install again Restarting your Simulator and the packager Terminal might work Close everything and build the app through Xcode might work Remove the build folder YOUR_PROJECT/ios/build/ and run react-native run-ios may work Upgrading your react-native using react-native upgrade More advance

Adding NSAllowsLocalNetworking to Info.plist

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

Port is already in useThis also means the “Port already in use”. Terminating a process on port 8081 Run the following command in the terminal 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 Missing Native code OR assets(images) There might be a chance where you could have accidentally deleted the native code or images, Manually re-adding the in the Build phase might solve the problem Proxy Settings If you are using proxies like Shadowsocks, Issue might be related to network settings and is very likely related to proxy settings. If a proxy is used, do not forget to set a bypass proxy for localhost and 127.0.0.1 addresses. OR Disable proxy everything should be fine.

https://powercoder23.wordpress.com/2017/10/29/solved-no-bundle-url-present/

These are some popular fixes used to solve the issue, hope it helps Sources: https://github.com/facebook/react-native/issues/12754 https://stackoverflow.com/questions/42610070/what-means-of-no-bundle-url-present-in-react-native

richardfelkl commented 4 years ago

I'm experiencing the same issue. Upgraded from RN 61.2 to 62.2. No solution mentioned above helps.

DylanVerstraete commented 4 years ago

Having the same issue here trying to build ios for production! No solution above helped.

React native version: 0.61.5 Xcode version: 11.4.1

Slals commented 4 years ago

Xcode version : 11.5

Same issue after manually upgrading from 0.61.5 to 0.62.2. I tried all stuff above but none was fruitful. Creating own main.bundlejs with react-native bundle only makes static bundle, it doesn't connect with the server.

No issue arround ports, it really seems the iOS build can't create the main.bundlejs automatically by executing node_modules/react-native/scripts/react-native-xcode.sh, but the script is not returning errors.

I have no idea yet, trying to upgrade to 0.63.0-rc1.

EDIT : upgrade to 0.63.0-rc1 didn't fix this issue. Have you guys some idea to know what's going on? I feel like this line "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh"; in project.pbxproj is the root of this issue, but I'm not so sure.

narcismihaitech commented 4 years ago

After struggling for days with this issue on 2 separate apps (in both cases the issue occurred after upgrading React Native), I finally decided to recreate the iOS project folder following this solution. Note that you may need to reinstall some libraries after recreation the folder, but it's the fastest solution that I've found that actually works.

Slals commented 4 years ago

Xcode version : 11.5 RN version : 0.63.0-rc1

I found something, not sure if it's the root of the issue for you guys.

In AppDelegate.m there is this snippet :

- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
{
  #if DEBUG
    return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  #else
    return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif
}

But it turns out DEBUG is not set while it should be. So the app is looking for a jsbundle which is not created since the command npx react-native run-ios does not create it.

I have no idea why DEBUG is not set to 1, all Swift params have the -DDEBUG... If anyone have an idea on this, it would be nice.

richardfelkl commented 4 years ago

I finally found out my issue. I was missing env var in XCode project FB_SONARKIT_ENABLED=1 in Build Settings -> Preprocessor Macros -> Debug.