From 53bff28f2babd5d550d5e7d8a5f46273d67f42d5 Mon Sep 17 00:00:00 2001 From: LouiseHsu Date: Wed, 16 Oct 2024 11:58:07 -0700 Subject: [PATCH] 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 Screenshot 2024-10-14 at 14 48 39 --- .../lib/src/macos/cocoapods.dart | 11 +++++ .../general.shard/macos/cocoapods_test.dart | 48 +++++++++++++++++++ 2 files changed, 59 insertions(+) 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();