diff --git a/packages/cli-doctor/src/tools/healthchecks/index.ts b/packages/cli-doctor/src/tools/healthchecks/index.ts index e7c870b62f..2116ff01b5 100644 --- a/packages/cli-doctor/src/tools/healthchecks/index.ts +++ b/packages/cli-doctor/src/tools/healthchecks/index.ts @@ -11,6 +11,7 @@ import cocoaPods from './cocoaPods'; import iosDeploy from './iosDeploy'; import {Healthchecks, HealthCheckCategory} from '../../types'; import loadConfig from '@react-native-community/cli-config'; +import xcodeEnv from './xcodeEnv'; export const HEALTHCHECK_TYPES = { ERROR: 'ERROR', @@ -55,7 +56,7 @@ export const getHealthchecks = ({contributor}: Options): Healthchecks => { ? { ios: { label: 'iOS', - healthchecks: [xcode, cocoaPods, iosDeploy], + healthchecks: [xcode, cocoaPods, iosDeploy, xcodeEnv], }, } : {}), diff --git a/packages/cli-doctor/src/tools/healthchecks/xcodeEnv.ts b/packages/cli-doctor/src/tools/healthchecks/xcodeEnv.ts new file mode 100644 index 0000000000..b54e4803fc --- /dev/null +++ b/packages/cli-doctor/src/tools/healthchecks/xcodeEnv.ts @@ -0,0 +1,21 @@ +import {HealthCheckInterface} from '../../types'; +import fs from "fs"; +import { promisify } from 'util'; + +export default { + label: '.xcode.env', + description: 'File to customize Xcode environment', + getDiagnostics: async () => { + return { + needsToBeFixed: fs.existsSync("./ios/.xcode.env") + }; + }, + runAutomaticFix: async () => { + const filePath = '/ios/.xcode.env'; + const src = "./node_modules/react-native/template" + filePath; + const dest = "." + filePath; + + const copyFileAsync = promisify(fs.copyFile); + await copyFileAsync(src, dest); + }, +} as HealthCheckInterface; diff --git a/packages/cli/src/commands/init/editTemplate.ts b/packages/cli/src/commands/init/editTemplate.ts index cf3a01c157..93115c947a 100644 --- a/packages/cli/src/commands/init/editTemplate.ts +++ b/packages/cli/src/commands/init/editTemplate.ts @@ -69,6 +69,7 @@ const UNDERSCORED_DOTFILES = [ 'editorconfig', 'bundle', 'ruby-version', + 'xcode.env' ]; async function processDotfiles(filePath: string) { diff --git a/packages/cli/src/tools/generator/copyProjectTemplateAndReplace.ts b/packages/cli/src/tools/generator/copyProjectTemplateAndReplace.ts index e7e0b45a38..77b71809c5 100644 --- a/packages/cli/src/tools/generator/copyProjectTemplateAndReplace.ts +++ b/packages/cli/src/tools/generator/copyProjectTemplateAndReplace.ts @@ -148,7 +148,8 @@ function translateFilePath(filePath: string) { .replace('_prettierrc.js', '.prettierrc.js') .replace('_bundle', '.bundle') .replace('_ruby-version', '.ruby-version') - .replace('_watchmanconfig', '.watchmanconfig'); + .replace('_watchmanconfig', '.watchmanconfig') + .replace('_xcode.env', '.xcode.env'); } function upgradeFileContentChangedCallback(