Avoid duplicating Pods-Runner xcconfig #includes (#75822)

This commit is contained in:
Jenn Magder 2021-02-11 14:11:15 -08:00 committed by GitHub
parent cc95c972b7
commit ba5e237e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 3 deletions

View File

@ -274,9 +274,10 @@ class CocoaPods {
final File file = xcodeProject.xcodeConfigFor(mode);
if (file.existsSync()) {
final String content = file.readAsStringSync();
final String include = '#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.${mode
.toLowerCase()}.xcconfig"';
if (!content.contains(include)) {
final String includeFile = 'Pods/Target Support Files/Pods-Runner/Pods-Runner.${mode
.toLowerCase()}.xcconfig';
final String include = '#include? "$includeFile"';
if (!content.contains(includeFile)) {
file.writeAsStringSync('$include\n$content', flush: true);
}
}

View File

@ -260,6 +260,34 @@ void main() {
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('does not include Pod config in xcconfig files, if legacy non-option include present', () async {
projectUnderTest.ios.podfile..createSync()..writeAsStringSync('Existing Podfile');
const String legacyDebugInclude = '#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig';
projectUnderTest.ios.xcodeConfigFor('Debug')
..createSync(recursive: true)
..writeAsStringSync(legacyDebugInclude);
const String legacyReleaseInclude = '#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig';
projectUnderTest.ios.xcodeConfigFor('Release')
..createSync(recursive: true)
..writeAsStringSync(legacyReleaseInclude);
final FlutterProject project = FlutterProject.fromPath('project');
await cocoaPodsUnderTest.setupPodfile(project.ios);
final String debugContents = projectUnderTest.ios.xcodeConfigFor('Debug').readAsStringSync();
// Redundant contains check, but this documents what we're testing--that the optional
// #include? doesn't get written in addition to the previous style #include.
expect(debugContents, isNot(contains('#include?')));
expect(debugContents, equals(legacyDebugInclude));
final String releaseContents = projectUnderTest.ios.xcodeConfigFor('Release').readAsStringSync();
expect(releaseContents, isNot(contains('#include?')));
expect(releaseContents, equals(legacyReleaseInclude));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => FakeProcessManager.any(),
});
});
group('Update xcconfig', () {