facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.22k stars 626 forks source link

[iOS]: No bundle URL present. Make sure you're running a packager server or have included a .jsbundle file in your application bundle. #1353

Closed LukasB-DEV closed 1 month ago

LukasB-DEV commented 2 months ago

Description

I Upgraded my React Native Projekt from 0.74.5 to 0.75.2 and now I am not able to run the App on a real IOS Device. In Simulator all works fine. On my IPhone, build with XCode, I get this error: image

I already tried things from https://github.com/facebook/react-native/issues/26331#issuecomment-551065731 and added the Build step but this has not worked for me.

Steps to reproduce

  1. Install React Native 0.74.5
  2. Upgrade it to 0.75.2
  3. try to run it on reals iPhone with XCode

React Native Version

0.75.2

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: "(8) x64 AMD Ryzen 7 5700X 8-Core Processor             "
  Memory: 798.54 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.17.0
    path: /usr/local/opt/node@20/bin/node
  Yarn: Not Found
  npm:
    version: 10.8.2
    path: /usr/local/opt/node@20/bin/npm
  Watchman:
    version: 2024.08.26.00
    path: /usr/local/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.2
    wanted: 0.75.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.

Reproducer

Repro

Screenshots and Videos

No response

react-native-bot commented 2 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
react-native-bot commented 2 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
cipolleschi commented 2 months ago

Thanks @LukasB-DEV for opening the issue. Just to make sure: Metro is running, right?

LukasB-DEV commented 2 months ago

Yes Metro is running. I first start metro with "npm start" and that build with XCode

cipolleschi commented 1 month ago

Ok, then this is something we have to investigate. Thanks for reporting this! QQ: are you behind a VPN, perhaps? Make sure that the device and the metro bundler are on the same network!

cortinico commented 1 month ago

Passing over to the Metro team

vchan023 commented 1 month ago

This may not be the fix for you but I was dealing with a similar issue, where metro would not see my real iPhone but worked with my simulator. I tried adding:

Privacy - Local Network Usage Description

to my info.plist to resolve another issue with local devices permissions pop up not appearing, and on the next 'yarn ios' metro successfully connected.

cipolleschi commented 1 month ago

Yes, it is related. If you deny connection to local networks on your device, it will start not connecting to Metro server running locally. Even if you go to settings and allow for network connection, it won't work right away.

The only solution seems to be:

  1. enable local networks from the settings
  2. restart your phone

I ended up in that scenario and restarting the phone solved it. Apparently, it is an iOS bug.

LukasB-DEV commented 1 month ago

I have set Local network Usage Discription: image

Local Networks from iPhone Settings are enabled but still the error. Or anything else i need to do?

cipolleschi commented 1 month ago

@LukasB-DEV that descriptor should not be needed because in the Info.plist we already have an Allow Local Networking set to YES.

Screenshot 2024-09-25 at 14 54 39

Double check that in the iphone's Settings > <Your App> the toggle for the Local Network is turned on. Then turn off the phone physically and turn it on.

It should work.

iliapnmrv commented 2 weeks ago

@cipolleschi Hey! Do you have any ideas why can't I see setting Local Network? I think it is the reason in my case and probably in others. It is definitely debug build, not release

iliapnmrv commented 2 weeks ago

So solution for me was Build Phases -> Bundle React Native code and images -> disable Run script: For install builds only it was enabled on my side for some reason :(

Gunndroid commented 2 weeks ago

So solution for me was Build Phases -> Bundle React Native code and images -> disable Run script: For install builds only it was enabled on my side for some reason :(

Thank you for this, actually gave up on a project for 2 weeks because I couldn't figure it out, working now because of this solution!

AndrArajo commented 1 week ago

I've had this problem for a few weeks and I've found the solution. For my project, the issue stemmed from how "Debug" was configured in the project.pbxproj file. The system was interpreting the debug mode as Release because GCC_PREPROCESSOR_DEFINITIONS was set with DEBUG=0, when it should have been DEBUG=1. I can search for the problem in this section.

GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", );

Alexufo commented 4 days ago

@cipolleschi it also may need "Required background modes" at Plist and check "Remote notification" in Sign&Capabilites