-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Fix error in react-native run-ios when Product Name and Scheme are inequal #10178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
d4e9495
Uses correct ios app file name so that react-native run-ios won't fai…
StevePotter 028535a
Improved regex and parsing slightly
StevePotter d9e2d2d
Fixed double spawnsync
StevePotter 93d3aab
Wrote build output to the console. Needed this becaeuse called to sp…
StevePotter 4db0df2
Merge branch 'master' into fixiosappname
StevePotter c48a6df
Switched a vew var keywords to let. Tightened up build output regex …
StevePotter ee2b353
Promisified runOnX and buildProject functions so buildProject could u…
StevePotter e37439d
Fixed build output regex to use a single capture group.
StevePotter 9501c1d
Merge branch 'master' into fixiosappname
StevePotter e357742
Merge branch 'fixiosappname' of github.com:StevePotter/react-native i…
StevePotter c01f837
Few style tweaks
StevePotter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -64,8 +64,7 @@ function runOnDeviceByUdid(udid, scheme, xcodeProject, devices) { | |
| } | ||
|
|
||
| function runOnSimulator(xcodeProject, args, inferredSchemeName, scheme){ | ||
| return new Promise((resolve) => | ||
| { | ||
| return new Promise((resolve) => { | ||
| try { | ||
| var simulators = JSON.parse( | ||
| child_process.execFileSync('xcrun', ['simctl', 'list', '--json', 'devices'], {encoding: 'utf8'}) | ||
|
|
@@ -90,11 +89,10 @@ function runOnSimulator(xcodeProject, args, inferredSchemeName, scheme){ | |
| resolve(selectedSimulator.udid) | ||
| }) | ||
| .then((udid) => buildProject(xcodeProject, udid, scheme)) | ||
| .then((appName) => | ||
| { | ||
| if (!appName) | ||
| .then((appName) => { | ||
| if (!appName) { | ||
| appName = inferredSchemeName; | ||
|
|
||
| } | ||
| const appPath = `build/Build/Products/Debug-iphonesimulator/${appName}.app`; | ||
| console.log(`Installing ${appPath}`); | ||
| child_process.spawnSync('xcrun', ['simctl', 'install', 'booted', appPath], {stdio: 'inherit'}); | ||
|
|
@@ -112,17 +110,17 @@ function runOnSimulator(xcodeProject, args, inferredSchemeName, scheme){ | |
|
|
||
| function runOnDevice(selectedDevice, scheme, xcodeProject){ | ||
| return buildProject(xcodeProject, selectedDevice.udid, scheme) | ||
| .then((appName) => | ||
| { | ||
| if (!appName) | ||
| .then((appName) => { | ||
| if (!appName) { | ||
| appName = scheme; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same nits as above |
||
| } | ||
| const iosDeployInstallArgs = [ | ||
| '--bundle', 'build/Build/Products/Debug-iphoneos/' + appName + '.app', | ||
| '--id' , selectedDevice.udid, | ||
| '--justlaunch' | ||
| ]; | ||
| console.log(`installing and launching your app on ${selectedDevice.name}...`); | ||
| let iosDeployOutput = child_process.spawnSync('ios-deploy', iosDeployInstallArgs, {encoding: 'utf8'}); | ||
| const iosDeployOutput = child_process.spawnSync('ios-deploy', iosDeployInstallArgs, {encoding: 'utf8'}); | ||
| if (iosDeployOutput.error) { | ||
| console.log(''); | ||
| console.log('** INSTALLATION FAILED **'); | ||
|
|
@@ -151,13 +149,12 @@ function buildProject(xcodeProject, udid, scheme) { | |
| buildOutput += data.toString(); | ||
| }); | ||
| buildProcess.stderr.on('data', function(data) { | ||
| console.log(data.toString()); | ||
| console.error(data.toString()); | ||
| }); | ||
| buildProcess.on('close', function(code) { | ||
| //FULL_PRODUCT_NAME is the actual file name of the app, which actually comes from the Product Name in the build config, which does not necessary match a scheme name, example output line: export FULL_PRODUCT_NAME="Super App Dev.app" | ||
| let productNameMatch = /export FULL_PRODUCT_NAME="*(.+).app/.exec(buildOutput); | ||
| if (productNameMatch && productNameMatch.length && productNameMatch.length > 1) | ||
| { | ||
| let productNameMatch = /export FULL_PRODUCT_NAME="?(.+).app/.exec(buildOutput); | ||
| if (productNameMatch && productNameMatch.length && productNameMatch.length > 1) { | ||
| return resolve(productNameMatch[1]);//0 is the full match, 1 is the app name | ||
| } | ||
| return buildProcess.error? reject(error) : resolve(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const simulatorsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left as var because simulators is used outside the context of the try/catch it's in. Turn it into a const and you get "simulators is not defined" error. You could pull it out of the try/catch, but then you have to use let. So I thought var was actually the best choice here. If you want, I'll add "let simulators;" above the try. What do you prefer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes,
let simulatorsoutside of the try-catch block would be the preferred style.