From dac028d496f749b4566e5fa58210b8fc64b94896 Mon Sep 17 00:00:00 2001 From: Mark Oswald Date: Fri, 1 Apr 2016 08:02:40 -0700 Subject: [PATCH] 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 --- local-cli/runIOS/runIOS.js | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/local-cli/runIOS/runIOS.js b/local-cli/runIOS/runIOS.js index 584d4ada4..8a92743b6 100644 --- a/local-cli/runIOS/runIOS.js +++ b/local-cli/runIOS/runIOS.js @@ -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(