Make iOS project path configurable by parameter in run-ios cli command
Summary:In projects where you have multiple apps or a different structure (ios is not the directory containing the xcode project) it would be helpful to have the option to configure the directory containing the xcode project when doing "react-native run-ios" As my PR does not change and does not affect UI it's hard to show a video ;-) Steps to reproduce are: 1. checkout facebook/react-native 2. run 'react-native run-ios' (it will fail) 3. npm link react-native (with my PR) 4. re-run 'react-native run-ios --ios-project-path Examples/Movies/ Now the simulator should open the Movies example app Closes https://github.com/facebook/react-native/pull/6134 Differential Revision: D3035188 fb-gh-sync-id: edb924ce3cca4e82161cdce3d25f321b03abc765 fbshipit-source-id: edb924ce3cca4e82161cdce3d25f321b03abc765
This commit is contained in:
parent
ef8ad82a62
commit
dac028d496
|
@ -27,7 +27,8 @@ function runIOS(argv, config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _runIOS(argv, config, resolve, reject) {
|
function _runIOS(argv, config, resolve, reject) {
|
||||||
const args = parseCommandLine([{
|
const args = parseCommandLine([
|
||||||
|
{
|
||||||
command: 'simulator',
|
command: 'simulator',
|
||||||
description: 'Explicitly set simulator to use',
|
description: 'Explicitly set simulator to use',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -38,16 +39,23 @@ function _runIOS(argv, config, resolve, reject) {
|
||||||
description: 'Explicitly set Xcode scheme to use',
|
description: 'Explicitly set Xcode scheme to use',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: false,
|
required: false,
|
||||||
}], argv);
|
}, {
|
||||||
|
command: 'project-path',
|
||||||
|
description: 'Path relative to project root where the Xcode project (.xcodeproj) lives. The default is \'ios\'.',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
default: 'ios',
|
||||||
|
}
|
||||||
|
], argv);
|
||||||
|
|
||||||
process.chdir('ios');
|
process.chdir(args['project-path']);
|
||||||
const xcodeProject = findXcodeProject(fs.readdirSync('.'));
|
const xcodeProject = findXcodeProject(fs.readdirSync('.'));
|
||||||
if (!xcodeProject) {
|
if (!xcodeProject) {
|
||||||
throw new Error(`Could not find Xcode project files in ios folder`);
|
throw new Error(`Could not find Xcode project files in ios folder`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const inferredSchemeName = path.basename(xcodeProject.name, path.extname(xcodeProject.name));
|
const inferredSchemeName = path.basename(xcodeProject.name, path.extname(xcodeProject.name));
|
||||||
const scheme = args.scheme || inferredSchemeName
|
const scheme = args.scheme || inferredSchemeName;
|
||||||
console.log(`Found Xcode ${xcodeProject.isWorkspace ? 'workspace' : 'project'} ${xcodeProject.name}`);
|
console.log(`Found Xcode ${xcodeProject.isWorkspace ? 'workspace' : 'project'} ${xcodeProject.name}`);
|
||||||
|
|
||||||
const simulators = parseIOSSimulatorsList(
|
const simulators = parseIOSSimulatorsList(
|
||||||
|
|
Loading…
Reference in New Issue