Add a tool warning when pod install does not work after adding a new test/watch/extension/other target with Xcode 16 (#156758)

Running `pod install` on Xcode projects with new test/targets in Xcode 16 will fail. Since this is a [Cocoapods bug](https://github.com/CocoaPods/CocoaPods/issues/12456), this PR adds a warning to the tool that links to a github work around and the current tracking issue.

Fixes https://github.com/flutter/flutter/issues/156733
<img width="567" alt="Screenshot 2024-10-14 at 14 48 39" src="https://github.com/user-attachments/assets/6befa601-4041-46fc-9ca2-f57662adda4a">
This commit is contained in:
LouiseHsu
2024-10-16 11:58:07 -07:00
committed by GitHub
parent 293ae2e5ab
commit 53bff28f2b
2 changed files with 59 additions and 0 deletions

View File

@@ -502,6 +502,17 @@ class CocoaPods {
);
}
}
} else if (stdout.contains('unknown ISA `PBXFileSystemSynchronizedRootGroup`')) {
// CocoaPods does not work with Xcode 16 since it has not yet been
// updated to handled synchronized
// groups/folders https://github.com/CocoaPods/CocoaPods/issues/12456
_logger.printError(
'Error: CocoaPods does not support Xcode 16 synchronized groups. '
'To fix your Xcode project, '
'see https://github.com/flutter/flutter/issues/156733#issuecomment-2415359014 '
'for a workaround.',
emphasis: true,
);
}
}

View File

@@ -517,6 +517,54 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by
);
});
testUsingContext('throws if using a version of Cocoapods '
'that is unable to handle synchronized folders/groups', () async {
final FlutterProject projectUnderTest = setupProjectUnderTest();
pretendPodIsInstalled();
pretendPodVersionIs('100.0.0');
fileSystem.file(fileSystem.path.join('project', 'ios', 'Podfile'))
..createSync()
..writeAsStringSync('Existing Podfile');
fakeProcessManager.addCommand(
const FakeCommand(
command: <String>['pod', 'install', '--verbose'],
workingDirectory: 'project/ios',
environment: <String, String>{
'COCOAPODS_DISABLE_STATS': 'true',
'LANG': 'en_US.UTF-8',
},
exitCode: 1,
// This output is the output that a real CocoaPods install would generate.
stdout: '''
### Command
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/bin/pod install
...
### Error
RuntimeError - `PBXGroup` attempted to initialize an object with unknown ISA `PBXFileSystemSynchronizedRootGroup` from attributes: `{"isa"=>"PBXFileSystemSynchronizedRootGroup", "explicitFileTypes"=>{}, "explicitFolders"=>[], "path"=>"RunnerTests", "sourceTree"=>"<group>"}`
If this ISA was generated by Xcode please file an issue: https://github.com/CocoaPods/Xcodeproj/issues/new
/opt/homebrew/Cellar/cocoapods/1.15.2_1/libexec/gems/xcodeproj-1.25.0/lib/xcodeproj/project/object.rb:359:in `rescue in object_with_uuid''',
),
);
await expectLater(cocoaPodsUnderTest.processPods(
xcodeProject: projectUnderTest.ios,
buildMode: BuildMode.debug,
), throwsToolExit());
expect(
logger.errorText,
contains(
'Error: CocoaPods does not support Xcode 16 synchronized groups. '
'To fix your Xcode project, '
'see https://github.com/flutter/flutter/issues/156733#issuecomment-2415359014 '
'for a workaround.',
),
);
});
testUsingContext('throws if plugin requires higher minimum iOS version using "platform"', () async {
final FlutterProject projectUnderTest = setupProjectUnderTest();
pretendPodIsInstalled();