Only run pod install on the first iOS build (#108205)
This commit is contained in:
@@ -62,7 +62,9 @@ class Fingerprinter {
|
||||
void writeFingerprint() {
|
||||
try {
|
||||
final Fingerprint fingerprint = buildFingerprint();
|
||||
_fileSystem.file(fingerprintPath).writeAsStringSync(fingerprint.toJson());
|
||||
final File fingerprintFile = _fileSystem.file(fingerprintPath);
|
||||
fingerprintFile.createSync(recursive: true);
|
||||
fingerprintFile.writeAsStringSync(fingerprint.toJson());
|
||||
} on Exception catch (e) {
|
||||
// Log exception and continue, fingerprinting is only a performance improvement.
|
||||
_logger.printTrace('Fingerprint write error: $e');
|
||||
|
||||
@@ -28,7 +28,6 @@ Future<void> processPodsIfNeeded(
|
||||
paths: <String>[
|
||||
xcodeProject.xcodeProjectInfoFile.path,
|
||||
xcodeProject.podfile.path,
|
||||
xcodeProject.generatedXcodePropertiesFile.path,
|
||||
globals.fs.path.join(
|
||||
Cache.flutterRoot!,
|
||||
'packages',
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import 'dart:convert' show json;
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/base/fingerprint.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/utils.dart';
|
||||
@@ -57,29 +58,33 @@ void main() {
|
||||
);
|
||||
expect(fingerprinter.doesFingerprintMatch(), isFalse);
|
||||
});
|
||||
|
||||
testWithoutContext('fingerprint does match if identical', () {
|
||||
fileSystem.file('a.dart').createSync();
|
||||
fileSystem.file('b.dart').createSync();
|
||||
|
||||
const String fingerprintPath = 'path/to/out.fingerprint';
|
||||
final Fingerprinter fingerprinter = Fingerprinter(
|
||||
fingerprintPath: 'out.fingerprint',
|
||||
fingerprintPath: fingerprintPath,
|
||||
paths: <String>['a.dart', 'b.dart'],
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
);
|
||||
fingerprinter.writeFingerprint();
|
||||
expect(fingerprinter.doesFingerprintMatch(), isTrue);
|
||||
expect(fileSystem.file(fingerprintPath), exists);
|
||||
});
|
||||
|
||||
testWithoutContext('fails to write fingerprint if inputs are missing', () {
|
||||
const String fingerprintPath = 'path/to/out.fingerprint';
|
||||
final Fingerprinter fingerprinter = Fingerprinter(
|
||||
fingerprintPath: 'out.fingerprint',
|
||||
fingerprintPath: fingerprintPath,
|
||||
paths: <String>['a.dart'],
|
||||
fileSystem: fileSystem,
|
||||
logger: BufferLogger.test(),
|
||||
);
|
||||
fingerprinter.writeFingerprint();
|
||||
expect(fileSystem.file('out.fingerprint').existsSync(), isFalse);
|
||||
expect(fileSystem.file(fingerprintPath), isNot(exists));
|
||||
});
|
||||
|
||||
group('Fingerprint', () {
|
||||
|
||||
@@ -11,15 +11,20 @@ import 'test_utils.dart';
|
||||
|
||||
void main() {
|
||||
test('flutter build ios --config only updates generated xcconfig file without performing build', () async {
|
||||
final String workingDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
|
||||
final String workingDirectory = fileSystem.path.join(
|
||||
getFlutterRoot(),
|
||||
'dev',
|
||||
'integration_tests',
|
||||
'flutter_gallery',
|
||||
);
|
||||
final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
|
||||
|
||||
await processManager.run(<String>[
|
||||
flutterBin,
|
||||
...getLocalEngineArguments(),
|
||||
...getLocalEngineArguments(),
|
||||
'clean',
|
||||
], workingDirectory: workingDirectory);
|
||||
final ProcessResult result = await processManager.run(<String>[
|
||||
final List<String> buildCommand = <String>[
|
||||
flutterBin,
|
||||
...getLocalEngineArguments(),
|
||||
'build',
|
||||
@@ -29,25 +34,48 @@ void main() {
|
||||
'--obfuscate',
|
||||
'--split-debug-info=info',
|
||||
'--no-codesign',
|
||||
], workingDirectory: workingDirectory);
|
||||
];
|
||||
final ProcessResult firstRunResult = await processManager.run(buildCommand, workingDirectory: workingDirectory);
|
||||
|
||||
printOnFailure('Output of flutter build ios:');
|
||||
printOnFailure(result.stdout.toString());
|
||||
printOnFailure(result.stderr.toString());
|
||||
final String firstRunStdout = firstRunResult.stdout.toString();
|
||||
printOnFailure('First run stdout: $firstRunStdout');
|
||||
printOnFailure('First run stderr: ${firstRunResult.stderr.toString()}');
|
||||
|
||||
expect(result.exitCode, 0);
|
||||
expect(firstRunResult.exitCode, 0);
|
||||
expect(firstRunStdout, contains('Running pod install'));
|
||||
|
||||
final File generatedConfig = fileSystem.file(
|
||||
fileSystem.path.join(workingDirectory, 'ios', 'Flutter', 'Generated.xcconfig'));
|
||||
final File generatedConfig = fileSystem.file(fileSystem.path.join(
|
||||
workingDirectory,
|
||||
'ios',
|
||||
'Flutter',
|
||||
'Generated.xcconfig',
|
||||
));
|
||||
|
||||
// Config is updated if command succeeded.
|
||||
expect(generatedConfig, exists);
|
||||
expect(generatedConfig.readAsStringSync(), contains('DART_OBFUSCATION=true'));
|
||||
|
||||
// file that only exists if app was fully built.
|
||||
final File frameworkPlist = fileSystem.file(
|
||||
fileSystem.path.join(workingDirectory, 'build', 'ios', 'iphoneos', 'Runner.app', 'AppFrameworkInfo.plist'));
|
||||
final File frameworkPlist = fileSystem.file(fileSystem.path.join(
|
||||
workingDirectory,
|
||||
'build',
|
||||
'ios',
|
||||
'iphoneos',
|
||||
'Runner.app',
|
||||
'AppFrameworkInfo.plist',
|
||||
));
|
||||
|
||||
expect(frameworkPlist, isNot(exists));
|
||||
|
||||
// Run again with no changes.
|
||||
final ProcessResult secondRunResult = await processManager.run(buildCommand, workingDirectory: workingDirectory);
|
||||
final String secondRunStdout = secondRunResult.stdout.toString();
|
||||
printOnFailure('Second run stdout: $secondRunStdout');
|
||||
printOnFailure('Second run stderr: ${secondRunResult.stderr.toString()}');
|
||||
|
||||
expect(secondRunResult.exitCode, 0);
|
||||
// Do not run "pod install" when nothing changes.
|
||||
expect(secondRunStdout, isNot(contains('pod install')));
|
||||
}, skip: !platform.isMacOS); // [intended] iOS builds only work on macos.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user