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

fix: adjust doctor command to work with custom ios/ folder location #1998

Conversation

szymonrybczak
Copy link
Collaborator

Summary:

Fixes #1989
Right now when looking for .xcode.env file, we look in directories defined in react-native.config.js. It fixes the problem for the brownfield setups, where very often there ios/ folder is not in the default location.

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Run this command:
node /path/to/react-native-cli/packages/cli/build/bin.js doctor

Should find the .xcode.env, and if it doesn't exist - after fixing issues by pressing f inside terminal, it should create the file in correct location.

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@szymonrybczak
Copy link
Collaborator Author

@sbalay Mind checking if it works in your custom setup? 🙏 Here's the guide for testing changes locally.

@sbalay
Copy link
Contributor

sbalay commented Jul 5, 2023

Hey 👋

Just tried it, seems to work fine!

Created a tiny PR to update the guide to test local changes that was missing cli-doctor in the linking step: #2000

Another side note is that, while playing around, I did the following in a normal react-native project:

mv ios other-ios
yarn react-native doctor

The cli worked fine and detected that the environment is correctly set up. When adding more logs to cli-doctor to check what was the inferred ios project folder, it was correctly set to other-ios. However, I didn't change anything anywhere else (didn't update react-native.config.js either). How did the cli manage to infer the correct folder?

@szymonrybczak
Copy link
Collaborator Author

Hello 👋 Thanks for testing!

How did the cli manage to infer the correct folder?

So before running every command CLI is running loadConfig() function that resolves config, and for iOS CLI is not looking for ios/ directory but is looking for Podfile, and then if the CLI found Podfile under some directory it does path.dirname on that directory - and that's because it is working even if we change default folder name. To be honest I didn't know that, anyway nice fun fact 😄

@szymonrybczak szymonrybczak force-pushed the fix/adjust-doctor-command-to-work-with-custom-location branch from f22d042 to b95e275 Compare July 7, 2023 06:48
@thymikee thymikee merged commit f1de95b into react-native-community:main Jul 12, 2023
@thymikee
Copy link
Member

cc @arushikesarwani94

Copy link
Contributor

@arushikesarwani94 arushikesarwani94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

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

Successfully merging this pull request may close these issues.

react-native doctor crashes when it fails to find the default Podfile
4 participants