Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Show Xcode compilation errors at end of build, suppress stdout and stderr from Xcode #113302

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

Merged
merged 2 commits into from
Oct 17, 2022

Conversation

jmagman
Copy link
Member

@jmagman jmagman commented Oct 12, 2022

  1. In xcode_backend prefix assemble stderr with error: to make them show up as compilation errors in the Xcode UI and the parsed XCResults. Example dart compilation error showing in Xcode:

Screen Shot 2022-10-11 at 4 29 02 PM

  1. Treat assemble build system exceptions as fatal, but only show stack traces in verbose mode. As far as I can tell no ExceptionMeasurement was ever fatal, so only showing stack traces in verbose mode shouldn't suppress previously displayed stack traces, since there were none. See Don't log stack traces to console on build failures #44966 and [flutter_tools] Allow the tool to suppress compilation errors. #58539 for some of the history of that TODO.

  2. Stop showing the final x stderr and stdout lines of the Xcode build, unless the xcresult can't be parsed. This should reduce the noise in the build failure.

  3. Stop showing the "missing development team" message when there is a more specific error to show.

This should make triaging issues easier, since the build error will be visible and obvious without --verbose.

Iteration on #22536
Fixes #32755
Fixes #113203
Fixes #100721
Fixes #98298

Compilation failure on iOS

Before

Screen Shot 2022-10-11 at 4 15 56 PM
Screen Shot 2022-10-11 at 4 29 55 PM

After

Screen Shot 2022-10-11 at 4 14 39 PM
Screen Shot 2022-10-11 at 4 29 02 PM

Other assemble failure on iOS

A file system exception

Before

No indication there is a file system issue.
Screen Shot 2022-10-11 at 4 24 06 PM

After

Screen Shot 2022-10-11 at 4 21 56 PM

Compilation failure on Android

Before

Screen Shot 2022-10-11 at 4 17 31 PM

After

There's one additional line:

Target kernel_snapshot failed: Exception

Screen Shot 2022-10-11 at 4 19 24 PM

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@jmagman jmagman added tool Affects the "flutter" command-line tool. See also t: labels. t: xcode "xcodebuild" on iOS and general Xcode project management labels Oct 12, 2022
@jmagman jmagman self-assigned this Oct 12, 2022
@flutter-dashboard flutter-dashboard bot added the platform-ios iOS applications specifically label Oct 12, 2022
}
if (!allowFail && result.exitCode != 0) {
stderr.write('${result.stderr}\n');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was redundant, echoError writes to stderr right above this.

@@ -414,14 +414,6 @@ Future<XcodeBuildResult> buildXcodeProject({
}
if (buildResult != null && buildResult.exitCode != 0) {
globals.printStatus('Failed to build iOS app');
if (buildResult.stderr.isNotEmpty) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop printing the Xcode output when we have more specific error to display, to reduce noise

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the assumption is that the actual error was already echo'd by xcode_backend?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that because the build failed there will be at least one error message from Xcode that will be parsed and already shown. That includes any failure from assemble, including a dart compilation issue.

@@ -265,49 +266,48 @@ Xcode's output:
blah

=== CLEAN TARGET url_launcher OF PROJECT Pods WITH CONFIGURATION Release ===
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed some of the irrelevant parts of the output of these tests to make it more concise.

@flutter-dashboard flutter-dashboard bot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Oct 12, 2022
if (resultStderr.isNotEmpty) {
final StringBuffer errorOutput = StringBuffer();
if (result.exitCode != 0) {
// "error:" prefix makes this show up as an Xcode compilation error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nifty

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nifty and totally undocumented, I don't even remember how I learned about this.

@@ -782,11 +774,21 @@ bool _needUpdateSigningIdentifier(XcodeBuildExecution? xcodeBuildExecution) {
//
// As detecting issues in stdout is not usually accurate, this should be used as a fallback when other issue detecting methods failed.
void _parseIssueInStdout(XcodeBuildExecution xcodeBuildExecution, Logger logger, XcodeBuildResult result) {
final String? stderr = result.stderr;
if (stderr != null && stderr.isNotEmpty) {
logger.printStatus('Error output from Xcode build:\n↳');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be logger.printError?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just moved, and it was printStatus before. Not sure why and I don't really want to change it now... Hopefully we almost never drop back to this fallback.

Copy link
Contributor

@christopherfujino christopherfujino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jmagman jmagman added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 17, 2022
@auto-submit auto-submit bot merged commit f059dd4 into flutter:master Oct 17, 2022
@jmagman jmagman deleted the xcode-error branch October 17, 2022 17:51
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Oct 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Oct 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Oct 18, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App c: contributor-productivity Team-specific productivity, code health, technical debt. platform-ios iOS applications specifically t: xcode "xcodebuild" on iOS and general Xcode project management tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
2 participants