-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Use xcpretty for iOS build output if installed #15607
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
Conversation
@facebook-github-bot label Core Team Generated by 🚫 dangerJS |
local-cli/runIOS/runIOS.js
Outdated
stdio: [ 0, 'pipe', 'ignore', ] | ||
}); | ||
} catch (error) { | ||
console.log(error) |
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.
semi: Missing semicolon.
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.
Crap.
local-cli/runIOS/runIOS.js
Outdated
stdio: [ 0, 'pipe', 'ignore', ] | ||
}); | ||
} catch (error) { | ||
console.log(error); |
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.
I don't think we should log this, having this error print out could be confusing.
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.
Good point- was just a relic of debug code. Will remove.
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.
Done.
local-cli/runIOS/runIOS.js
Outdated
if (!verbose) { | ||
var xcpretty = xcprettyAvailable(); | ||
if (xcpretty) { | ||
var xcprettyProcess = child_process.spawn('xcpretty', [], { stdio: ['pipe', process.stdout, process.stderr] }); |
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.
I'd rather avoid using var scoping here and just use let/const instead.
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.
Normally I agree, but I was hoping to avoid running the synchronous xcprettyAvailable
function if I could avoid it when verbose is enabled. I can flatten this out if this is not considered an issue.
I suppose I could just declare the the let outside the block. Feels less clean to me, but whatever you want! 👍
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.
Yea I was just thinking declaring the let outside the block
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.
Done.
local-cli/runIOS/runIOS.js
Outdated
@@ -160,30 +170,44 @@ function buildProject(xcodeProject, udid, scheme, configuration = 'Debug', launc | |||
'-derivedDataPath', 'build', | |||
]; | |||
console.log(`Building using "xcodebuild ${xcodebuildArgs.join(' ')}"`); | |||
let xcpretty, xcprettyProcess; |
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.
Why do we need xcpretty
process?
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.
It is to store a reference to the spawned child process to pipe the console output to. Needs to be declared at the same scope as the xcpretty variable to be accessible in subsequent blocks.
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.
Sorry, I meant "Why do we need xcpretty
variable here?".
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.
(It looks redundant, we already have *process
.)
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.
xcpretty is simply a boolean to show that it is available. Could possibly be renamed to be more specific if that is a point of confusion.
One can only start the process if it is available. A couple other switches depend on it as well.
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.
Essentially I don't want a variable to possibly Have different types based on state. Variables are cheap, and I believe this makes it more clear.
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.
I am okay with both renaming or using xcprettyProcess
as a flag.
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.
I think we should get rid of xcpretty and just use xcprettyProcess as the flag.
just use xcpretty - either is falsy or contains the process
} catch (error) { | ||
return false; | ||
} | ||
return true; |
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.
no-trailing-spaces: Trailing spaces not allowed.
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.
@eslint-bot Idk what you're smoking.
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
@shergin Are you ok with this PR? |
@hramos can you take a look at this? |
Something (probably unrelated to this PR) went wrong when I tried to land it. |
@shergin has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: iOS/xcodebuild logging output sucks. It's completely unreadable because of how xcodebuild takes arguments. Fortunately a ruby gem has existed to fix this for years: xcpretty. You simply pipe xcodebuilds output to xcpretty and it cleans it up, showing relevant info in a more readable format. This PR implements xcpretty output. It checks to see if xcpretty is in PATH, then uses it by default if it is, and can be disabled using a --verbose cli flag. - Create a project from master - run `react-native run-ios` - Confirm output looks like this: ```tabrindle-mbp:shop-rn tabrindle$ make Scanning 662 folders for symlinks in /Users/tabrindle/Developer/react-native/node_modules (5ms) Found Xcode project Shop.xcodeproj We couldn't boot your defined simulator due to an already booted simulator. We are limited to one simulator launched at a time. Launching iPhone 6 (iOS 10.3)... Building using "xcodebuild -project Shop.xcodeproj -configuration Debug -scheme Shop -destination id=0CD9ABF3-A8E4-43D6-A52B-F437FF0F45A0 -derivedDataPath build" ▸ Building React/yoga [Debug] ▸ Check Dependencies ▸ Building React/double-conversion [Debug] ▸ Check Dependencies ▸ Running script 'Install Third Party' ▸ Building React/third-party [Debug] ▸ Check Dependencies ▸ Building React/jschelpers [Debug] ▸ Check Dependencies ▸ Building React/cxxreact [Debug] ▸ Check Dependencies ▸ Building React/React [Debug] ▸ Check Dependencies ▸ Running script 'Start Packager' ▸ Running script 'Include RCTJSCProfiler' ▸ Building RCTSettings/RCTSettings [Debug] ▸ Check Dependencies ▸ Building BVLinearGradient/BVLinearGradient [Debug] ▸ Check Dependencies ▸ Building RCTActionSheet/RCTActionSheet [Debug] ▸ Check Dependencies ▸ Building RCTLinking/RCTLinking [Debug] ▸ Check Dependencies ▸ Building RCTWebSocket/fishhook [Debug] ▸ Check Dependencies ▸ Building RCTWebSocket/RCTWebSocket [Debug] ▸ Check Dependencies ▸ Building RCTText/RCTText [Debug] ▸ Check Dependencies ▸ Building RCTNetwork/RCTNetwork [Debug] ▸ Check Dependencies ▸ Building RCTAnimation/RCTAnimation [Debug] ▸ Check Dependencies ▸ Building RCTGeolocation/RCTGeolocation [Debug] ▸ Check Dependencies ▸ Building ReactNativeNavigation/ReactNativeNavigation [Debug] ▸ Check Dependencies ▸ Building RNI18n/RNI18n [Debug] ▸ Check Dependencies ▸ Building RCTImage/RCTImage [Debug] ▸ Check Dependencies ▸ Building RNVectorIcons/RNVectorIcons [Debug] ▸ Check Dependencies ▸ Building RCTVibration/RCTVibration [Debug] ▸ Check Dependencies ▸ Building Shop/Shop [Debug] ▸ Check Dependencies ▸ Running script 'Bundle React Native code and images' ▸ Building Shop/ShopTests [Debug] ▸ Check Dependencies ▸ Build Succeeded Installing build/Build/Products/Debug-iphonesimulator/Shop.app Launching com.marketamerica.MAMobile com.marketamerica.MAMobile: 43497``` - run `react-native run-ios --verbose` - confirm output looks as normal Nothing else should be affected. This is simply a developer experience change. If xcpretty is not already installed, nothing will change at all. Many of us using fastlane have been spoiled by this for years. Closes facebook/react-native#15607 Differential Revision: D5740684 Pulled By: shergin fbshipit-source-id: 09ef21414b8b65be92595b19502b843fa943403d
iOS/xcodebuild logging output sucks. It's completely unreadable because of how xcodebuild takes arguments. Fortunately a ruby gem has existed to fix this for years: xcpretty. You simply pipe xcodebuilds output to xcpretty and it cleans it up, showing relevant info in a more readable format.
This PR implements xcpretty output. It checks to see if xcpretty is in PATH, then uses it by default if it is, and can be disabled using a --verbose cli flag.
Test Plan
react-native run-ios