Skip to content

Commit

Permalink
Make iOS project path configurable by parameter in run-ios cli command
Browse files Browse the repository at this point in the history
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 facebook#6134

Differential Revision: D3035188

fb-gh-sync-id: edb924ce3cca4e82161cdce3d25f321b03abc765
fbshipit-source-id: edb924ce3cca4e82161cdce3d25f321b03abc765
  • Loading branch information
mroswald authored and Facebook Github Bot 6 committed Apr 1, 2016
1 parent ef8ad82 commit dac028d
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions local-cli/runIOS/runIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,35 @@ function runIOS(argv, config) {
}

function _runIOS(argv, config, resolve, reject) {
const args = parseCommandLine([{
command: 'simulator',
description: 'Explicitly set simulator to use',
type: 'string',
required: false,
default: 'iPhone 6',
}, {
command: 'scheme',
description: 'Explicitly set Xcode scheme to use',
type: 'string',
required: false,
}], argv);
const args = parseCommandLine([
{
command: 'simulator',
description: 'Explicitly set simulator to use',
type: 'string',
required: false,
default: 'iPhone 6',
}, {
command: 'scheme',
description: 'Explicitly set Xcode scheme to use',
type: 'string',
required: false,
}, {
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(
Expand Down

0 comments on commit dac028d

Please sign in to comment.