Skip to content

Commit e35ecd9

Browse files
auto-submit[bot]auto-submit[bot]
andauthored
Reverts "Clean before building when framework headers change (#177512)" (#177610)
<!-- start_original_pr_link --> Reverts: #177512 <!-- end_original_pr_link --> <!-- start_initiating_author --> Initiated by: vashworth <!-- end_initiating_author --> <!-- start_revert_reason --> Reason for reverting: May cause error: ``` Error (Xcode): Could not delete `/build/ios/Release-iphoneos` because it was not created by the build system and it is not a subfolder of derived data. ``` <!-- end_revert_reason --> <!-- start_original_pr_author --> Original PR Author: vashworth <!-- end_original_pr_author --> <!-- start_reviewers --> Reviewed By: {bkonyi} <!-- end_reviewers --> <!-- start_revert_body --> This change reverts the following previous change: Starting with Xcode 26, when a precompiled file changes (like a header file in the Flutter framework), it throws an error. This PR adds a fingerprinter to track changes to the headers. If the fingerprinting detects a change, it cleans before building. This only applies to Xcode 26 and incremental builds. Fresh builds should not clean. Fixes #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 <!-- end_revert_body --> Co-authored-by: auto-submit[bot] <[email protected]>
1 parent b5d2ed6 commit e35ecd9

File tree

5 files changed

+11
-497
lines changed

5 files changed

+11
-497
lines changed

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

Lines changed: 10 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import 'package:unified_analytics/unified_analytics.dart';
1010

1111
import '../artifacts.dart';
1212
import '../base/file_system.dart';
13-
import '../base/fingerprint.dart';
1413
import '../base/io.dart';
1514
import '../base/logger.dart';
1615
import '../base/process.dart';
1716
import '../base/project_migrator.dart';
1817
import '../base/utils.dart';
19-
import '../base/version.dart';
2018
import '../build_info.dart';
2119
import '../cache.dart';
2220
import '../darwin/darwin.dart';
@@ -272,16 +270,6 @@ Future<XcodeBuildResult> buildXcodeProject({
272270
'file version field before submitting to the App Store.',
273271
);
274272
}
275-
final XcodeSdk sdk = environmentType == EnvironmentType.physical
276-
? XcodeSdk.IPhoneOS
277-
: XcodeSdk.IPhoneSimulator;
278-
final String buildDirectoryPath = getIosBuildDirectory();
279-
final Directory buildDirectory = globals.fs.directory(buildDirectoryPath);
280-
final bool incrementalBuild =
281-
buildDirectory.existsSync() &&
282-
buildDirectory.listSync().any(
283-
(FileSystemEntity entity) => entity.basename.contains(sdk.platformName),
284-
);
285273

286274
Map<String, String>? autoSigningConfigs;
287275

@@ -322,7 +310,7 @@ Future<XcodeBuildResult> buildXcodeProject({
322310
);
323311
}
324312
}
325-
await processPodsIfNeeded(project.ios, buildDirectoryPath, buildInfo.mode);
313+
await processPodsIfNeeded(project.ios, getIosBuildDirectory(), buildInfo.mode);
326314
if (configOnly) {
327315
return XcodeBuildResult(success: true);
328316
}
@@ -334,26 +322,6 @@ Future<XcodeBuildResult> buildXcodeProject({
334322
configuration,
335323
];
336324

337-
// Check the public headers before checking Xcode version so headers fingerprinter is created
338-
// regardless of Xcode version.
339-
final bool headersChanged = publicHeadersChanged(
340-
environmentType: environmentType,
341-
mode: buildInfo.mode,
342-
buildDirectory: buildDirectoryPath,
343-
artifacts: globals.artifacts,
344-
fileSystem: globals.fs,
345-
logger: globals.logger,
346-
);
347-
final Version? xcodeVersion = globals.xcode?.currentVersion;
348-
if (headersChanged &&
349-
incrementalBuild &&
350-
(xcodeVersion != null && xcodeVersion >= Version(26, 0, 0))) {
351-
// Xcode 26 changed the way headers are pre-compiled and will throw an error if the headers
352-
// have changed since the last time they were compiled. To avoid this error, clean before
353-
// building if headers have changed.
354-
buildCommands.addAll(<String>['clean', 'build']);
355-
}
356-
357325
if (globals.logger.isVerbose) {
358326
// An environment variable to be passed to xcode_backend.sh determining
359327
// whether to echo back executed commands.
@@ -383,7 +351,7 @@ Future<XcodeBuildResult> buildXcodeProject({
383351
scheme,
384352
if (buildAction !=
385353
XcodeBuildAction.archive) // dSYM files aren't copied to the archive if BUILD_DIR is set.
386-
'BUILD_DIR=${globals.fs.path.absolute(buildDirectoryPath)}',
354+
'BUILD_DIR=${globals.fs.path.absolute(getIosBuildDirectory())}',
387355
]);
388356
}
389357

@@ -405,14 +373,20 @@ Future<XcodeBuildResult> buildXcodeProject({
405373
return XcodeBuildResult(success: false);
406374
}
407375
} else {
408-
buildCommands.addAll(<String>['-sdk', sdk.platformName]);
376+
if (environmentType == EnvironmentType.physical) {
377+
buildCommands.addAll(<String>['-sdk', XcodeSdk.IPhoneOS.platformName]);
378+
} else {
379+
buildCommands.addAll(<String>['-sdk', XcodeSdk.IPhoneSimulator.platformName]);
380+
}
409381
}
410382

411383
buildCommands.add('-destination');
412384
if (deviceID != null) {
413385
buildCommands.add('id=$deviceID');
386+
} else if (environmentType == EnvironmentType.physical) {
387+
buildCommands.add(XcodeSdk.IPhoneOS.genericPlatform);
414388
} else {
415-
buildCommands.add(sdk.genericPlatform);
389+
buildCommands.add(XcodeSdk.IPhoneSimulator.genericPlatform);
416390
}
417391

418392
if (activeArch != null) {
@@ -654,52 +628,6 @@ Future<XcodeBuildResult> buildXcodeProject({
654628
}
655629
}
656630

657-
/// Check if the Flutter framework's public headers have changed since last built.
658-
bool publicHeadersChanged({
659-
required BuildMode mode,
660-
required EnvironmentType environmentType,
661-
required String buildDirectory,
662-
required Artifacts? artifacts,
663-
required FileSystem fileSystem,
664-
required Logger logger,
665-
}) {
666-
final String? basePath = artifacts?.getArtifactPath(
667-
Artifact.flutterFramework,
668-
platform: TargetPlatform.ios,
669-
mode: mode,
670-
environmentType: environmentType,
671-
);
672-
if (basePath == null) {
673-
return false;
674-
}
675-
final Directory headersDirectory = fileSystem.directory(
676-
fileSystem.path.join(basePath, 'Headers'),
677-
);
678-
if (!headersDirectory.existsSync()) {
679-
return false;
680-
}
681-
final List<String> files = headersDirectory
682-
.listSync()
683-
.map<String>((FileSystemEntity header) => header.path)
684-
.toList();
685-
686-
final String fingerprintPath = fileSystem.path.join(
687-
buildDirectory,
688-
'framework_public_headers.fingerprint',
689-
);
690-
final fingerprinter = Fingerprinter(
691-
fingerprintPath: fingerprintPath,
692-
paths: files,
693-
fileSystem: fileSystem,
694-
logger: logger,
695-
);
696-
final bool headersChanged = !fingerprinter.doesFingerprintMatch();
697-
if (headersChanged) {
698-
fingerprinter.writeFingerprint();
699-
}
700-
return headersChanged;
701-
}
702-
703631
/// Extended attributes applied by Finder can cause code signing errors. Remove them.
704632
/// https://developer.apple.com/library/archive/qa/qa1940/_index.html
705633
Future<void> removeFinderExtendedAttributes(

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:args/command_runner.dart';
66
import 'package:file/memory.dart';
77
import 'package:flutter_tools/src/android/android_sdk.dart';
8-
import 'package:flutter_tools/src/artifacts.dart';
98
import 'package:flutter_tools/src/base/common.dart';
109
import 'package:flutter_tools/src/base/file_system.dart';
1110
import 'package:flutter_tools/src/base/logger.dart';
@@ -315,7 +314,6 @@ void main() {
315314
]),
316315
Platform: () => macosPlatform,
317316
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
318-
Artifacts: () => Artifacts.test(),
319317
},
320318
);
321319

@@ -352,7 +350,6 @@ void main() {
352350
Pub: ThrowingPub.new,
353351
Platform: () => macosPlatform,
354352
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
355-
Artifacts: () => Artifacts.test(),
356353
},
357354
);
358355

@@ -390,7 +387,6 @@ void main() {
390387
Pub: ThrowingPub.new,
391388
Platform: () => macosPlatform,
392389
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
393-
Artifacts: () => Artifacts.test(),
394390
},
395391
);
396392

@@ -427,7 +423,6 @@ void main() {
427423
Pub: ThrowingPub.new,
428424
Platform: () => macosPlatform,
429425
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
430-
Artifacts: () => Artifacts.test(),
431426
},
432427
);
433428

@@ -475,7 +470,6 @@ void main() {
475470
Pub: ThrowingPub.new,
476471
Platform: () => macosPlatform,
477472
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
478-
Artifacts: () => Artifacts.test(),
479473
},
480474
);
481475

@@ -514,7 +508,6 @@ void main() {
514508
Pub: ThrowingPub.new,
515509
Platform: () => macosPlatform,
516510
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
517-
Artifacts: () => Artifacts.test(),
518511
},
519512
);
520513

@@ -552,7 +545,6 @@ void main() {
552545
Pub: ThrowingPub.new,
553546
Platform: () => macosPlatform,
554547
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
555-
Artifacts: () => Artifacts.test(),
556548
},
557549
);
558550

@@ -588,7 +580,6 @@ void main() {
588580
Pub: ThrowingPub.new,
589581
Platform: () => macosPlatform,
590582
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
591-
Artifacts: () => Artifacts.test(),
592583
},
593584
);
594585

@@ -651,7 +642,6 @@ void main() {
651642
FileSystemUtils: () => FileSystemUtils(fileSystem: fileSystem, platform: macosPlatform),
652643
Analytics: () => fakeAnalytics,
653644
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
654-
Artifacts: () => Artifacts.test(),
655645
},
656646
);
657647

@@ -713,7 +703,6 @@ void main() {
713703
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
714704
Pub: ThrowingPub.new,
715705
Analytics: () => fakeAnalytics,
716-
Artifacts: () => Artifacts.test(),
717706
},
718707
);
719708

@@ -777,7 +766,6 @@ void main() {
777766
),
778767
Pub: ThrowingPub.new,
779768
Analytics: () => fakeAnalytics,
780-
Artifacts: () => Artifacts.test(),
781769
},
782770
);
783771
});
@@ -821,7 +809,6 @@ void main() {
821809
Pub: ThrowingPub.new,
822810
Platform: () => macosPlatform,
823811
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
824-
Artifacts: () => Artifacts.test(),
825812
},
826813
);
827814

@@ -870,7 +857,6 @@ void main() {
870857
Pub: ThrowingPub.new,
871858
Platform: () => macosPlatform,
872859
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
873-
Artifacts: () => Artifacts.test(),
874860
},
875861
);
876862

@@ -924,7 +910,6 @@ void main() {
924910
Pub: ThrowingPub.new,
925911
Platform: () => macosPlatform,
926912
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
927-
Artifacts: () => Artifacts.test(),
928913
},
929914
);
930915

@@ -963,7 +948,6 @@ void main() {
963948
Pub: ThrowingPub.new,
964949
Platform: () => macosPlatform,
965950
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
966-
Artifacts: () => Artifacts.test(),
967951
},
968952
);
969953

@@ -1020,7 +1004,6 @@ void main() {
10201004
Pub: ThrowingPub.new,
10211005
Platform: () => macosPlatform,
10221006
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1023-
Artifacts: () => Artifacts.test(),
10241007
},
10251008
);
10261009

@@ -1068,7 +1051,6 @@ void main() {
10681051
Pub: ThrowingPub.new,
10691052
Platform: () => macosPlatform,
10701053
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1071-
Artifacts: () => Artifacts.test(),
10721054
},
10731055
);
10741056

@@ -1110,7 +1092,6 @@ void main() {
11101092
Pub: ThrowingPub.new,
11111093
Platform: () => macosPlatform,
11121094
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1113-
Artifacts: () => Artifacts.test(),
11141095
},
11151096
);
11161097

@@ -1169,7 +1150,6 @@ void main() {
11691150
Pub: ThrowingPub.new,
11701151
Platform: () => macosPlatform,
11711152
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1172-
Artifacts: () => Artifacts.test(),
11731153
},
11741154
);
11751155

@@ -1214,7 +1194,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
12141194
Pub: ThrowingPub.new,
12151195
Platform: () => macosPlatform,
12161196
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1217-
Artifacts: () => Artifacts.test(),
12181197
},
12191198
);
12201199

@@ -1257,7 +1236,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
12571236
Platform: () => macosPlatform,
12581237
XcodeProjectInterpreter: () =>
12591238
FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null),
1260-
Artifacts: () => Artifacts.test(),
12611239
},
12621240
);
12631241

@@ -1301,7 +1279,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
13011279
EnvironmentType: () => EnvironmentType.physical,
13021280
Platform: () => macosPlatform,
13031281
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1304-
Artifacts: () => Artifacts.test(),
13051282
},
13061283
);
13071284

@@ -1343,7 +1320,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
13431320
Platform: () => macosPlatform,
13441321
XcodeProjectInterpreter: () =>
13451322
FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null),
1346-
Artifacts: () => Artifacts.test(),
13471323
},
13481324
);
13491325

@@ -1387,7 +1363,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
13871363
Platform: () => macosPlatform,
13881364
XcodeProjectInterpreter: () =>
13891365
FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null),
1390-
Artifacts: () => Artifacts.test(),
13911366
},
13921367
);
13931368

@@ -1438,7 +1413,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
14381413
Platform: () => macosPlatform,
14391414
XcodeProjectInterpreter: () =>
14401415
FakeXcodeProjectInterpreterWithBuildSettings(developmentTeam: null),
1441-
Artifacts: () => Artifacts.test(),
14421416
},
14431417
);
14441418
});
@@ -1485,7 +1459,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
14851459
Pub: ThrowingPub.new,
14861460
Platform: () => macosPlatform,
14871461
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1488-
Artifacts: () => Artifacts.test(),
14891462
},
14901463
);
14911464

@@ -1534,7 +1507,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
15341507
Pub: ThrowingPub.new,
15351508
Platform: () => macosPlatform,
15361509
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1537-
Artifacts: () => Artifacts.test(),
15381510
},
15391511
);
15401512

@@ -1592,7 +1564,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
15921564
Pub: ThrowingPub.new,
15931565
Platform: () => macosPlatform,
15941566
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1595-
Artifacts: () => Artifacts.test(),
15961567
},
15971568
);
15981569

@@ -1634,7 +1605,6 @@ Runner requires a provisioning profile. Select a provisioning profile in the Sig
16341605
Pub: ThrowingPub.new,
16351606
Platform: () => macosPlatform,
16361607
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
1637-
Artifacts: () => Artifacts.test(),
16381608
},
16391609
);
16401610
});

0 commit comments

Comments
 (0)