cli
cli copied to clipboard
fix: properly create .xcode.env file with doctors auto fix
Summary:
Noticed that doctor does not create .xcode.env file when it should.
It was happening because this command was failing silently:
const templateIosPath = path.dirname(
require.resolve('react-native/template/ios'),
);
Test Plan:
Create fresh project and then delete .xcode.env file. Then run doctor command and try to autofix the error.
❯ npx react-native doctor
Common
✓ Node.js
✓ yarn
✓ Watchman - Used for watching changes in the filesystem when in development mode
Android
✓ JDK
✓ Android Studio - Required for building and installing your app on Android
✓ Android SDK - Required for building and installing your app on Android
✓ ANDROID_HOME
iOS
✓ Xcode - Required for building and installing your app on iOS
✓ CocoaPods - Required for installing iOS dependencies
● ios-deploy - Required for installing your app on a physical device with the CLI
✖ .xcode.env - File to customize Xcode environment
Errors: 1
Warnings: 1
Attempting to fix 1 issue...
iOS
⠋ .xcode.env%
Run doctor again and error is still present:
❯ npx react-native doctor
Common
✓ Node.js
✓ yarn
✓ Watchman - Used for watching changes in the filesystem when in development mode
Android
✓ JDK
✓ Android Studio - Required for building and installing your app on Android
✓ Android SDK - Required for building and installing your app on Android
✓ ANDROID_HOME
iOS
✓ Xcode - Required for building and installing your app on iOS
✓ CocoaPods - Required for installing iOS dependencies
● ios-deploy - Required for installing your app on a physical device with the CLI
✖ .xcode.env - File to customize Xcode environment
@cipolleschi since you've added this feature with #1585 can I have your eyes on this please?
It looks good to me, thanks for taking the time to fix this.
Just a question: does it now works properly also with a newly created app? If not, could you fix that as well?
Well.. there's another issue with that - when I create fresh project with npx react-native init the _xcode.env file is not renamed. That's actually is how I've stumbled on the issue with doctor not being able to fix it. But the issue with renaming the file does not happen for everyone, just checked on second macbook and it works fine on it. Will keep an eye on the issue as well.
Thank you so much for checking this as well!