Unverified Commit ba5e237e authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

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

parent cc95c972
......@@ -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);
}
}
......
......@@ -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', () {
......
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