-
Notifications
You must be signed in to change notification settings - Fork 906
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(iOS): remove unintended flags from build-ios (#2078)
* refactor(iOS): remove unintended flags from build-ios * test: update snapshot * docs: move binary-path and list-devices to run-ios
- Loading branch information
Showing
11 changed files
with
208 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/cli-platform-ios/src/commands/buildIOS/buildOptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
export type BuildFlags = { | ||
mode?: string; | ||
target?: string; | ||
verbose?: boolean; | ||
scheme?: string; | ||
xcconfig?: string; | ||
buildFolder?: string; | ||
interactive?: boolean; | ||
destination?: string; | ||
extraParams?: string[]; | ||
}; | ||
|
||
export const buildOptions = [ | ||
{ | ||
name: '--mode <string>', | ||
description: | ||
'Explicitly set the scheme configuration to use. This option is case sensitive.', | ||
}, | ||
{ | ||
name: '--scheme <string>', | ||
description: 'Explicitly set Xcode scheme to use', | ||
}, | ||
{ | ||
name: '--destination <string>', | ||
description: 'Explicitly extend destination e.g. "arch=x86_64"', | ||
}, | ||
{ | ||
name: '--verbose', | ||
description: 'Do not use xcbeautify or xcpretty even if installed', | ||
}, | ||
{ | ||
name: '--xcconfig [string]', | ||
description: 'Explicitly set xcconfig to use', | ||
}, | ||
{ | ||
name: '--buildFolder <string>', | ||
description: | ||
'Location for iOS build artifacts. Corresponds to Xcode\'s "-derivedDataPath".', | ||
}, | ||
{ | ||
name: '--extra-params <string>', | ||
description: 'Custom params that will be passed to xcodebuild command.', | ||
parse: (val: string) => val.split(' '), | ||
}, | ||
{ | ||
name: '--target <string>', | ||
description: 'Explicitly set Xcode target to use.', | ||
}, | ||
{ | ||
name: '--interactive', | ||
description: | ||
'Explicitly select which scheme and configuration to use before running a build', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/cli-platform-ios/src/commands/buildIOS/getConfiguration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import chalk from 'chalk'; | ||
import {IOSProjectInfo} from '@react-native-community/cli-types'; | ||
import {logger} from '@react-native-community/cli-tools'; | ||
import {selectFromInteractiveMode} from '../../tools/selectFromInteractiveMode'; | ||
import {getProjectInfo} from '../../tools/getProjectInfo'; | ||
import {checkIfConfigurationExists} from '../../tools/checkIfConfigurationExists'; | ||
import type {BuildFlags} from './buildOptions'; | ||
import {getBuildConfigurationFromXcScheme} from '../../tools/getBuildConfigurationFromXcScheme'; | ||
|
||
export async function getConfiguration( | ||
xcodeProject: IOSProjectInfo, | ||
sourceDir: string, | ||
args: BuildFlags, | ||
) { | ||
const projectInfo = getProjectInfo(); | ||
|
||
if (args.mode) { | ||
checkIfConfigurationExists(projectInfo, args.mode); | ||
} | ||
|
||
let scheme = args.scheme || projectInfo.schemes[0]; | ||
let mode = | ||
args.mode || | ||
getBuildConfigurationFromXcScheme(scheme, 'Debug', sourceDir, projectInfo); | ||
|
||
if (args.interactive) { | ||
const selection = await selectFromInteractiveMode({ | ||
scheme, | ||
mode, | ||
projectInfo, | ||
}); | ||
|
||
if (selection.scheme) { | ||
scheme = selection.scheme; | ||
} | ||
|
||
if (selection.mode) { | ||
mode = selection.mode; | ||
} | ||
} | ||
|
||
logger.info( | ||
`Found Xcode ${ | ||
xcodeProject.isWorkspace ? 'workspace' : 'project' | ||
} "${chalk.bold(xcodeProject.name)}"`, | ||
); | ||
|
||
return {scheme, mode}; | ||
} |
22 changes: 22 additions & 0 deletions
22
packages/cli-platform-ios/src/commands/buildIOS/getXcodeProjectAndDir.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {IOSProjectConfig} from '@react-native-community/cli-types'; | ||
import {CLIError} from '@react-native-community/cli-tools'; | ||
|
||
export function getXcodeProjectAndDir( | ||
iosProjectConfig: IOSProjectConfig | undefined, | ||
) { | ||
if (!iosProjectConfig) { | ||
throw new CLIError( | ||
'iOS project folder not found. Are you sure this is a React Native project?', | ||
); | ||
} | ||
|
||
const {xcodeProject, sourceDir} = iosProjectConfig; | ||
|
||
if (!xcodeProject) { | ||
throw new CLIError( | ||
`Could not find Xcode project files in "${sourceDir}" folder`, | ||
); | ||
} | ||
|
||
return {xcodeProject, sourceDir}; | ||
} |
Oops, something went wrong.