mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Add guided error for precompiled cache error (#177327)
Starting with Xcode 26, when a precompiled file changes (like a header file in the Flutter framework), it throws an error. This PR parses for that error and gives a guided error message, telling them to do `flutter clean`. Fixes https://github.com/flutter/flutter/issues/176462. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
This commit is contained in:
parent
6db955d74f
commit
b970827eaa
@ -918,6 +918,12 @@ _XCResultIssueHandlingResult _handleXCResultIssue({
|
||||
missingModule: missingModule,
|
||||
);
|
||||
}
|
||||
} else if (message.toLowerCase().contains('has been modified since')) {
|
||||
return _XCResultIssueHandlingResult(
|
||||
requiresProvisioningProfile: false,
|
||||
hasProvisioningProfileIssue: false,
|
||||
modifiedPrecompiledSource: true,
|
||||
);
|
||||
}
|
||||
return _XCResultIssueHandlingResult(
|
||||
requiresProvisioningProfile: false,
|
||||
@ -937,6 +943,7 @@ Future<bool> _handleIssues(
|
||||
var requiresProvisioningProfile = false;
|
||||
var hasProvisioningProfileIssue = false;
|
||||
var issueDetected = false;
|
||||
var modifiedPrecompiledSource = false;
|
||||
String? missingPlatform;
|
||||
final duplicateModules = <String>[];
|
||||
final missingModules = <String>[];
|
||||
@ -962,6 +969,7 @@ Future<bool> _handleIssues(
|
||||
if (handlingResult.missingModule != null) {
|
||||
missingModules.add(handlingResult.missingModule!);
|
||||
}
|
||||
modifiedPrecompiledSource = handlingResult.modifiedPrecompiledSource;
|
||||
issueDetected = true;
|
||||
}
|
||||
} else if (xcResult != null) {
|
||||
@ -1032,6 +1040,13 @@ Future<bool> _handleIssues(
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (modifiedPrecompiledSource) {
|
||||
logger.printError(
|
||||
'════════════════════════════════════════════════════════════════════════════════\n'
|
||||
'A precompiled file has been changed since last built. Please run "flutter clean" to clear '
|
||||
'the cache.\n'
|
||||
'════════════════════════════════════════════════════════════════════════════════',
|
||||
);
|
||||
}
|
||||
return issueDetected;
|
||||
}
|
||||
@ -1169,6 +1184,7 @@ class _XCResultIssueHandlingResult {
|
||||
this.missingPlatform,
|
||||
this.duplicateModule,
|
||||
this.missingModule,
|
||||
this.modifiedPrecompiledSource = false,
|
||||
});
|
||||
|
||||
/// An issue indicates that user didn't provide the provisioning profile.
|
||||
@ -1186,6 +1202,10 @@ class _XCResultIssueHandlingResult {
|
||||
/// An issue indicates a module was imported but not found, potentially due
|
||||
/// to it being Swift Package Manager compatible only.
|
||||
final String? missingModule;
|
||||
|
||||
/// An issue indicates that a source file, such as a header in the Flutter framework, has
|
||||
/// changed since last built. This requires "flutter clean" to resolve.
|
||||
final bool modifiedPrecompiledSource;
|
||||
}
|
||||
|
||||
const _kResultBundlePath = 'temporary_xcresult_bundle';
|
||||
|
||||
@ -670,6 +670,56 @@ duplicate symbol '_$s29plugin_1_name23PluginNamePluginC9setDouble3key5valueySS_S
|
||||
Pub: ThrowingPub.new,
|
||||
},
|
||||
);
|
||||
|
||||
testWithoutContext('parses file has been modified error', () async {
|
||||
const buildCommands = <String>['xcrun', 'cc', 'blah'];
|
||||
final buildResult = XcodeBuildResult(
|
||||
success: false,
|
||||
stdout: '',
|
||||
xcodeBuildExecution: XcodeBuildExecution(
|
||||
buildCommands: buildCommands,
|
||||
appDirectory: '/blah/blah',
|
||||
environmentType: EnvironmentType.physical,
|
||||
buildSettings: buildSettings,
|
||||
),
|
||||
xcResult: XCResult.test(
|
||||
issues: <XCResultIssue>[
|
||||
XCResultIssue.test(
|
||||
message:
|
||||
"File 'path/to/Flutter.framework/Headers/FlutterPlugin.h' has been modified since "
|
||||
"the precompiled header 'path/to/Runner.build/Objects-normal/arm64/Runner-primary-Bridging-header.pch'"
|
||||
' was built: size changed (was 18306, now 16886)',
|
||||
subType: 'Error',
|
||||
),
|
||||
XCResultIssue.test(
|
||||
message:
|
||||
"File 'path/to/Flutter.framework/Headers/FlutterEngine.h' has been modified since "
|
||||
"the precompiled header 'path/to/Runner.build/Objects-normal/arm64/Runner-primary-Bridging-header.pch'"
|
||||
' was built: size changed (was 18306, now 16886)',
|
||||
subType: 'Error',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
final fs = MemoryFileSystem.test();
|
||||
final project = FakeFlutterProject(fileSystem: fs, usesSwiftPackageManager: true);
|
||||
project.ios.podfile.createSync(recursive: true);
|
||||
await diagnoseXcodeBuildFailure(
|
||||
buildResult,
|
||||
logger: logger,
|
||||
analytics: fakeAnalytics,
|
||||
fileSystem: fs,
|
||||
platform: FlutterDarwinPlatform.ios,
|
||||
project: project,
|
||||
);
|
||||
expect(
|
||||
logger.errorText,
|
||||
contains(
|
||||
'A precompiled file has been changed since last built. Please run "flutter clean" to '
|
||||
'clear the cache.',
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('Upgrades project.pbxproj for old asset usage', () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user