Unverified Commit a8da7ced authored by Chris Yang's avatar Chris Yang Committed by GitHub

Hide default bundle id error when xcresult detects an error (#101993)

parent 1756ccc5
......@@ -581,16 +581,6 @@ Future<void> diagnoseXcodeBuildFailure(XcodeBuildResult result, Usage flutterUsa
// Fallback to use stdout to detect and print issues.
_parseIssueInStdout(xcodeBuildExecution, logger, result);
}
if (xcodeBuildExecution != null
&& xcodeBuildExecution.environmentType == EnvironmentType.physical
&& (xcodeBuildExecution.buildSettings['PRODUCT_BUNDLE_IDENTIFIER']?.contains('com.example') ?? false)) {
logger.printError('');
logger.printError('It appears that your application still contains the default signing identifier.');
logger.printError("Try replacing 'com.example' with your signing id in Xcode:");
logger.printError(' open ios/Runner.xcworkspace');
return;
}
}
/// xcodebuild <buildaction> parameter (see man xcodebuild for details).
......@@ -757,6 +747,14 @@ bool _handleIssues(XCResult? xcResult, Logger logger, XcodeBuildExecution? xcode
logger.printError('');
logger.printError("Also try selecting 'Product > Build' to fix the problem.");
}
if (!issueDetected && _needUpdateSigningIdentifier(xcodeBuildExecution)) {
issueDetected = true;
logger.printError('');
logger.printError('It appears that your application still contains the default signing identifier.');
logger.printError("Try replacing 'com.example' with your signing id in Xcode:");
logger.printError(' open ios/Runner.xcworkspace');
}
return issueDetected;
}
......@@ -769,6 +767,14 @@ bool _missingDevelopmentTeam(XcodeBuildExecution? xcodeBuildExecution) {
!<String>['DEVELOPMENT_TEAM', 'PROVISIONING_PROFILE'].any(
xcodeBuildExecution.buildSettings.containsKey);
}
// Return `true` if the signing identifier needs to be updated.
bool _needUpdateSigningIdentifier(XcodeBuildExecution? xcodeBuildExecution) {
return xcodeBuildExecution != null
&& xcodeBuildExecution.environmentType == EnvironmentType.physical
&& (xcodeBuildExecution.buildSettings['PRODUCT_BUNDLE_IDENTIFIER']?.contains('com.example') ?? false);
}
// Detects and handles errors from stdout.
//
// As detecting issues in stdout is not usually accurate, this should be used as a fallback when other issue detecting methods failed.
......
......@@ -480,7 +480,7 @@ void main() {
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
});
testUsingContext('Display xcresult issues with default bundle identifier.', () async {
testUsingContext('Default bundle identifier error should be hidden if there is another xcresult issue.', () async {
final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles();
......@@ -492,7 +492,7 @@ void main() {
expect(testLogger.errorText, contains("Use of undeclared identifier 'asdas'"));
expect(testLogger.errorText, contains('/Users/m/Projects/test_create/ios/Runner/AppDelegate.m:7:56'));
expect(testLogger.errorText, contains('It appears that your application still contains the default signing identifier.'));
expect(testLogger.errorText, isNot(contains('It appears that your application still contains the default signing identifier.')));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
......@@ -508,6 +508,33 @@ void main() {
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(productBundleIdentifier: 'com.example'),
});
testUsingContext('Show default bundle identifier error if there are no other errors.', () async {
final BuildCommand command = BuildCommand();
_createMinimalMockProjectFiles();
await expectLater(
createTestCommandRunner(command).run(const <String>['build', 'ios', '--no-pub']),
throwsToolExit(),
);
expect(testLogger.errorText, contains('It appears that your application still contains the default signing identifier.'));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.list(<FakeCommand>[
xattrCommand,
_setUpFakeXcodeBuildHandler(exitCode: 1, onRun: () {
fileSystem.systemTempDirectory.childDirectory(_xcBundleFilePath).createSync();
}),
_setUpXCResultCommand(stdout: kSampleResultJsonNoIssues),
_setUpRsyncCommand(),
]),
Platform: () => macosPlatform,
EnvironmentType: () => EnvironmentType.physical,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(productBundleIdentifier: 'com.example'),
});
testUsingContext('Display xcresult issues with no provisioning profile.', () async {
final BuildCommand command = BuildCommand();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment