react-native-community / upgrade-support

A central community-backed place to request and give help when upgrading your app.
MIT License
251 stars 2 forks source link

Upgraded to RM 0.73 - Metro bundler not connected to app when running in iOS Simulator #264

Closed plindsay closed 3 months ago

plindsay commented 3 months ago

Environment

System: OS: macOS 14.4 CPU: (10) arm64 Apple M2 Pro Memory: 86.38 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 20.6.1 path: ~/.nvm/versions/node/v20.6.1/bin/node Yarn: version: 1.22.19 path: /opt/homebrew/bin/yarn npm: version: 9.8.1 path: ~/.nvm/versions/node/v20.6.1/bin/npm Watchman: version: 2024.03.18.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.12.1 path: /Users/phil/.rbenv/shims/pod SDKs: iOS SDK: Platforms:

Things I’ve done to figure out my issue

Upgrading version

From 0.71.17 to 0.73.6

Description

I can successfully create an iOS build (using npx react-native run-ios) however the Metro bundler doesn't seem to connect to the app or create the bundle. Before the upgrade I would start Metro in one terminal window via yarn start and then npx react-native run-ios in another terminal window. This would work great and Metro would 'watch' changes and reload the app in the Simulator.

Now, after the upgrade, the connection with the iOS app seems to be no longer there, i.e. the bundle is not created and it doesn't 'watch' any changes to the code.

If I hit 'r' in the Metro window it says

'No apps connected. Sending "reload" to all React Native apps failed. Make sure your app is running in the simulator or on a phone connected via USB.'

Everything works fine when I test on Android though using the same workflow - e.g. yarn start in one terminal windown, and npx react-native run-android in another terminal window.

It seems somehow this part of the iOS build has been removed. I'm a bit stuck on why this has happened and how to resolve it.

Reproducible demo

Run yarn startin one terminal window and thennpx react-native run-ios` in another terminal window, and check that Metro creates the bundle and watches for changes.

plindsay commented 3 months ago

I found the problem - https://stackoverflow.com/a/64895016/134823

Not sure why this changed, but changing the scheme in Xcode to Debug connected the app to Metro 👍