diff --git a/packages/flutter_tools/lib/src/macos/cocoapods.dart b/packages/flutter_tools/lib/src/macos/cocoapods.dart index 631c933f75..bdff25e363 100644 --- a/packages/flutter_tools/lib/src/macos/cocoapods.dart +++ b/packages/flutter_tools/lib/src/macos/cocoapods.dart @@ -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, + ); } } diff --git a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart index 16d64d78ad..652551f081 100644 --- a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart @@ -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: ['pod', 'install', '--verbose'], + workingDirectory: 'project/ios', + environment: { + '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"=>""}` +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();