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:
Mark Oswald 2016-04-01 08:02:40 -07:00 committed by Facebook Github Bot 6
parent ef8ad82a62
commit dac028d496
1 changed files with 22 additions and 14 deletions

View File

@ -27,7 +27,8 @@ function runIOS(argv, config) {
}
function _runIOS(argv, config, resolve, reject) {
const args = parseCommandLine([{
const args = parseCommandLine([
{
command: 'simulator',
description: 'Explicitly set simulator to use',
type: 'string',
@ -38,16 +39,23 @@ function _runIOS(argv, config, resolve, reject) {
description: 'Explicitly set Xcode scheme to use',
type: 'string',
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('.'));
if (!xcodeProject) {
throw new Error(`Could not find Xcode project files in ios folder`);
}
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}`);
const simulators = parseIOSSimulatorsList(