Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[πŸ“š] Incorrect iOS Setup Guide – Unable To Connect To Metro Bundler #8246

Closed
julian-dotcom opened this issue Jan 23, 2025 · 5 comments

Comments

@julian-dotcom
Copy link

Documentation Feedback

The first step in the iOS setup guide led to an issue, where my app couldn't connect to the Metro Bundler.
https://rnfirebase.io/#configure-firebase-with-ios-credentials

Image

The solution to this problem was the following:

  • According to the guide, you should import #import <Firebase.h> right after #import "AppDelegate.h" at the top of AppDelegate.mm
  • However, the problem is that importing Firebase before #import <React/RCTBundleURLProvider.h> causes bundling to fail
  • Presumably, Firebase is called before a connection to the Metro bundler is established
  • It works again if you import #import <Firebase.h> after #import <React/RCTBundleURLProvider.h>
@mikehardy
Copy link
Collaborator

mikehardy commented Jan 23, 2025

I don't reproduce that. In react-native 0.76+ the template moved to Swift, so it is just a tiny bit different now, however in my build reproduction script from the previous release branch I sliced Firebase.h import in directly after AppDelegate as documented, and it worked perfectly every time:

https://github.com/mikehardy/rnfbdemo/blob/04b101e880c4c79943d6ec12cebbc7f04c70c72e/make-demo.sh#L93

I run that thing a lot. It always worked? So I can't reproduce, and no one else has ever mentioned it?

Additional confirmation for my assertion this is not reproducible and possible project-specific, the expo plugin we host (and which I assume tons of people use) also slices it in directly after AppDelegate and it has not resulted in any bug reports:

if (!contents.includes('#import <Firebase/Firebase.h>')) {
contents = contents.replace(
/#import "AppDelegate.h"/g,
`#import "AppDelegate.h"
#import <Firebase/Firebase.h>`,
);
}

I'm curious - If you can demonstrate a minimal + clean reproduction of this I could inspect more - but with those two heavy-usage counterfactuals linked above there's a high burden to demonstrating it

(moving a header import location shouldn't really change much as far as I know - so not a huge change, but understanding the "why" of it is critical since this would be a pretty subtle thing and might point at a deeper problem)

@zkteco-home
Copy link

in react native 0.77,/ios/{projectName}/AppDelegate.mm file (or AppDelegate.m removed,so please correct ios setup guide for RN0.77

@julian-dotcom
Copy link
Author

@mikehardy , thanks a lot for investigating this. I had very consistent problems with connecting the app to the metro bundler until I imported #import <Firebase.h> after #import <React/RCTBundleURLProvider.h>.

But if you cannot reproduce, it may be project specific, or may have had something to do with my cache.

@mikehardy
Copy link
Collaborator

in react native 0.77,/ios/{projectName}/AppDelegate.mm file (or AppDelegate.m removed,so please correct ios setup guide for RN0.77

@zkteco-home you are right! It's Swift now. Just as fast as posting a comment, can click the Edit button on the top right of the docs page and follow through the super-fast github web UI for a PR to the docs where you saw it? This is the general process for any improvement you see. Please do not remove the references to the old AppDelegate.m or .mm, as people upgrade slowly. Just keep those as a reference to react-native before 0.77, thanks

@mikehardy
Copy link
Collaborator

@julian-dotcom if I could reproduce I'd happily change that guidance - just need to understand the what+why first. My only guess is that somehow the same compiler symbol is defined twice in two separate libraries, and used incompatibly. if that's the case, knowing what that symbol could be is potentially interesting, as your solution may be allowing you to connect to Metro consistently now, but your whole app might just be working "by coincidence" so to speak. Not a stable place to be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants