Skip to content

Commit ab86c79

Browse files
authored
Revert "Print pretty error when xcodebuild fails due to missing simulator" (#130504)
Reverts flutter/flutter#130286
1 parent 604010e commit ab86c79

6 files changed

Lines changed: 1 addition & 468 deletions

File tree

packages/flutter_tools/lib/src/ios/mac.dart

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'dart:async';
66

7-
import 'package:meta/meta.dart';
87
import 'package:process/process.dart';
98

109
import '../artifacts.dart';
@@ -42,21 +41,6 @@ import 'xcresult.dart';
4241
const String kConcurrentRunFailureMessage1 = 'database is locked';
4342
const String kConcurrentRunFailureMessage2 = 'there are two concurrent builds running';
4443

45-
/// User message when missing platform required to use Xcode.
46-
///
47-
/// Starting with Xcode 15, the simulator is no longer downloaded with Xcode
48-
/// and must be downloaded and installed separately.
49-
@visibleForTesting
50-
String missingPlatformInstructions(String simulatorVersion) => '''
51-
════════════════════════════════════════════════════════════════════════════════
52-
$simulatorVersion is not installed. To download and install the platform, open
53-
Xcode, select Xcode > Settings > Platforms, and click the GET button for the
54-
required platform.
55-
56-
For more information, please visit:
57-
https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
58-
════════════════════════════════════════════════════════════════════════════════''';
59-
6044
class IMobileDevice {
6145
IMobileDevice({
6246
required Artifacts artifacts,
@@ -716,11 +700,6 @@ _XCResultIssueHandlingResult _handleXCResultIssue({required XCResultIssue issue,
716700
return _XCResultIssueHandlingResult(requiresProvisioningProfile: true, hasProvisioningProfileIssue: true);
717701
} else if (message.toLowerCase().contains('provisioning profile')) {
718702
return _XCResultIssueHandlingResult(requiresProvisioningProfile: false, hasProvisioningProfileIssue: true);
719-
} else if (message.toLowerCase().contains('ineligible destinations')) {
720-
final String? missingPlatform = _parseMissingPlatform(message);
721-
if (missingPlatform != null) {
722-
return _XCResultIssueHandlingResult(requiresProvisioningProfile: false, hasProvisioningProfileIssue: false, missingPlatform: missingPlatform);
723-
}
724703
}
725704
return _XCResultIssueHandlingResult(requiresProvisioningProfile: false, hasProvisioningProfileIssue: false);
726705
}
@@ -730,7 +709,6 @@ bool _handleIssues(XCResult? xcResult, Logger logger, XcodeBuildExecution? xcode
730709
bool requiresProvisioningProfile = false;
731710
bool hasProvisioningProfileIssue = false;
732711
bool issueDetected = false;
733-
String? missingPlatform;
734712

735713
if (xcResult != null && xcResult.parseSuccess) {
736714
for (final XCResultIssue issue in xcResult.issues) {
@@ -741,7 +719,6 @@ bool _handleIssues(XCResult? xcResult, Logger logger, XcodeBuildExecution? xcode
741719
if (handlingResult.requiresProvisioningProfile) {
742720
requiresProvisioningProfile = true;
743721
}
744-
missingPlatform = handlingResult.missingPlatform;
745722
issueDetected = true;
746723
}
747724
} else if (xcResult != null) {
@@ -761,8 +738,6 @@ bool _handleIssues(XCResult? xcResult, Logger logger, XcodeBuildExecution? xcode
761738
logger.printError(' open ios/Runner.xcworkspace');
762739
logger.printError('');
763740
logger.printError("Also try selecting 'Product > Build' to fix the problem.");
764-
} else if (missingPlatform != null) {
765-
logger.printError(missingPlatformInstructions(missingPlatform), emphasis: true);
766741
}
767742

768743
return issueDetected;
@@ -798,41 +773,18 @@ void _parseIssueInStdout(XcodeBuildExecution xcodeBuildExecution, Logger logger,
798773
&& (result.stdout?.contains('requires a provisioning profile. Select a provisioning profile in the Signing & Capabilities editor') ?? false)) {
799774
logger.printError(noProvisioningProfileInstruction, emphasis: true);
800775
}
801-
802-
if (stderr != null && stderr.contains('Ineligible destinations')) {
803-
final String? version = _parseMissingPlatform(stderr);
804-
if (version != null) {
805-
logger.printError(missingPlatformInstructions(version), emphasis: true);
806-
}
807-
}
808-
}
809-
810-
String? _parseMissingPlatform(String message) {
811-
final RegExp pattern = RegExp(r'error:(.*?) is not installed\. To use with Xcode, first download and install the platform');
812-
final RegExpMatch? match = pattern.firstMatch(message);
813-
if (match != null) {
814-
final String? version = match.group(1);
815-
return version;
816-
}
817-
return null;
818776
}
819777

820778
// The result of [_handleXCResultIssue].
821779
class _XCResultIssueHandlingResult {
822780

823-
_XCResultIssueHandlingResult({
824-
required this.requiresProvisioningProfile,
825-
required this.hasProvisioningProfileIssue,
826-
this.missingPlatform,
827-
});
781+
_XCResultIssueHandlingResult({required this.requiresProvisioningProfile, required this.hasProvisioningProfileIssue});
828782

829783
// An issue indicates that user didn't provide the provisioning profile.
830784
final bool requiresProvisioningProfile;
831785

832786
// An issue indicates that there is a provisioning profile issue.
833787
final bool hasProvisioningProfileIssue;
834-
835-
final String? missingPlatform;
836788
}
837789

838790
const String _kResultBundlePath = 'temporary_xcresult_bundle';

packages/flutter_tools/lib/src/ios/xcresult.dart

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,6 @@ class XCResult {
104104
issueDiscarder: issueDiscarders,
105105
));
106106
}
107-
108-
final Object? actionsMap = resultJson['actions'];
109-
if (actionsMap is Map<String, Object?>) {
110-
final List<XCResultIssue> actionIssues = _parseActionIssues(actionsMap, issueDiscarders: issueDiscarders);
111-
issues.addAll(actionIssues);
112-
}
113-
114107
return XCResult._(issues: issues);
115108
}
116109

@@ -390,84 +383,3 @@ List<XCResultIssue> _parseIssuesFromIssueSummariesJson({
390383
}
391384
return issues;
392385
}
393-
394-
List<XCResultIssue> _parseActionIssues(
395-
Map<String, Object?> actionsMap, {
396-
required List<XCResultIssueDiscarder> issueDiscarders,
397-
}) {
398-
// Example of json:
399-
// {
400-
// "actions" : {
401-
// "_values" : [
402-
// {
403-
// "actionResult" : {
404-
// "_type" : {
405-
// "_name" : "ActionResult"
406-
// },
407-
// "issues" : {
408-
// "_type" : {
409-
// "_name" : "ResultIssueSummaries"
410-
// },
411-
// "testFailureSummaries" : {
412-
// "_type" : {
413-
// "_name" : "Array"
414-
// },
415-
// "_values" : [
416-
// {
417-
// "_type" : {
418-
// "_name" : "TestFailureIssueSummary",
419-
// "_supertype" : {
420-
// "_name" : "IssueSummary"
421-
// }
422-
// },
423-
// "issueType" : {
424-
// "_type" : {
425-
// "_name" : "String"
426-
// },
427-
// "_value" : "Uncategorized"
428-
// },
429-
// "message" : {
430-
// "_type" : {
431-
// "_name" : "String"
432-
// },
433-
// "_value" : "Unable to find a destination matching the provided destination specifier:\n\t\t{ id:1234D567-890C-1DA2-34E5-F6789A0123C4 }\n\n\tIneligible destinations for the \"Runner\" scheme:\n\t\t{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 17.0 is not installed. To use with Xcode, first download and install the platform }"
434-
// }
435-
// }
436-
// ]
437-
// }
438-
// }
439-
// }
440-
// }
441-
// ]
442-
// }
443-
// }
444-
final List<XCResultIssue> issues = <XCResultIssue>[];
445-
final Object? actionsValues = actionsMap['_values'];
446-
if (actionsValues is! List<Object?>) {
447-
return issues;
448-
}
449-
450-
for (final Object? actionValue in actionsValues) {
451-
if (actionValue is!Map<String, Object?>) {
452-
continue;
453-
}
454-
final Object? actionResult = actionValue['actionResult'];
455-
if (actionResult is! Map<String, Object?>) {
456-
continue;
457-
}
458-
final Object? actionResultIssues = actionResult['issues'];
459-
if (actionResultIssues is! Map<String, Object?>) {
460-
continue;
461-
}
462-
final Object? testFailureSummaries = actionResultIssues['testFailureSummaries'];
463-
if (testFailureSummaries is Map<String, Object?>) {
464-
issues.addAll(_parseIssuesFromIssueSummariesJson(
465-
type: XCResultIssueType.error,
466-
issueSummariesJson: testFailureSummaries,
467-
issueDiscarder: issueDiscarders,
468-
));
469-
}
470-
}
471-
472-
return issues;
473-
}

packages/flutter_tools/test/commands.shard/hermetic/build_ios_test.dart

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -638,37 +638,6 @@ void main() {
638638
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
639639
});
640640

641-
testUsingContext('Extra error message for missing simulator platform in xcresult bundle.', () async {
642-
final BuildCommand command = BuildCommand(
643-
androidSdk: FakeAndroidSdk(),
644-
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
645-
fileSystem: MemoryFileSystem.test(),
646-
logger: BufferLogger.test(),
647-
osUtils: FakeOperatingSystemUtils(),
648-
);
649-
650-
createMinimalMockProjectFiles();
651-
652-
await expectLater(
653-
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
654-
throwsToolExit(),
655-
);
656-
657-
expect(testLogger.errorText, contains(missingPlatformInstructions('iOS 17.0')));
658-
}, overrides: <Type, Generator>{
659-
FileSystem: () => fileSystem,
660-
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
661-
xattrCommand,
662-
setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
663-
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
664-
}),
665-
setUpXCResultCommand(stdout: kSampleResultJsonWithActionIssues),
666-
setUpRsyncCommand(),
667-
]),
668-
Platform: () => macosPlatform,
669-
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
670-
});
671-
672641
testUsingContext('Delete xcresult bundle before each xcodebuild command.', () async {
673642
final BuildCommand command = BuildCommand(
674643
androidSdk: FakeAndroidSdk(),

packages/flutter_tools/test/general.shard/ios/mac_test.dart

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -245,44 +245,6 @@ Error launching application on iPhone.''',
245245
);
246246
});
247247

248-
testWithoutContext('fallback to stdout: Ineligible destinations', () async {
249-
final Map<String, String> buildSettingsWithDevTeam = <String, String>{
250-
'PRODUCT_BUNDLE_IDENTIFIER': 'test.app',
251-
'DEVELOPMENT_TEAM': 'a team',
252-
};
253-
final XcodeBuildResult buildResult = XcodeBuildResult(
254-
success: false,
255-
stderr: '''
256-
Launching lib/main.dart on iPhone in debug mode...
257-
Signing iOS app for device deployment using developer identity: "iPhone Developer: test@flutter.io (1122334455)"
258-
Running Xcode build... 1.3s
259-
Failed to build iOS app
260-
Error output from Xcode build:
261-
262-
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
263-
{ id:1234D567-890C-1DA2-34E5-F6789A0123C4 }
264-
265-
Ineligible destinations for the "Runner" scheme:
266-
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device, error:iOS 17.0 is not installed. To use with Xcode, first download and install the platform }
267-
268-
Could not build the precompiled application for the device.
269-
270-
Error launching application on iPhone.''',
271-
xcodeBuildExecution: XcodeBuildExecution(
272-
buildCommands: <String>['xcrun', 'xcodebuild', 'blah'],
273-
appDirectory: '/blah/blah',
274-
environmentType: EnvironmentType.physical,
275-
buildSettings: buildSettingsWithDevTeam,
276-
),
277-
);
278-
279-
await diagnoseXcodeBuildFailure(buildResult, testUsage, logger);
280-
expect(
281-
logger.errorText,
282-
contains(missingPlatformInstructions('iOS 17.0')),
283-
);
284-
});
285-
286248
testWithoutContext('No development team shows message', () async {
287249
final XcodeBuildResult buildResult = XcodeBuildResult(
288250
success: false,

packages/flutter_tools/test/general.shard/ios/xcresult_test.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,6 @@ void main() {
204204
expect(result.parsingErrorMessage, isNull);
205205
});
206206

207-
testWithoutContext(
208-
'correctly parse sample result json with action issues.', () async {
209-
final XCResultGenerator generator = setupGenerator(resultJson: kSampleResultJsonWithActionIssues);
210-
final XCResultIssueDiscarder discarder = XCResultIssueDiscarder(typeMatcher: XCResultIssueType.warning);
211-
final XCResult result = await generator.generate(issueDiscarders: <XCResultIssueDiscarder>[discarder]);
212-
expect(result.issues.length, 1);
213-
expect(result.issues.first.type, XCResultIssueType.error);
214-
expect(result.issues.first.subType, 'Uncategorized');
215-
expect(result.issues.first.message, contains('Unable to find a destination matching the provided destination specifier'));
216-
expect(result.parseSuccess, isTrue);
217-
expect(result.parsingErrorMessage, isNull);
218-
});
219-
220207
testWithoutContext(
221208
'error: `xcresulttool get` process fail should return an `XCResult` with stderr as `parsingErrorMessage`.',
222209
() async {

0 commit comments

Comments
 (0)