From 62c08f4471b527bd14c692a636aba60b89dee593 Mon Sep 17 00:00:00 2001 From: Victoria Ashworth <15619084+vashworth@users.noreply.github.com> Date: Thu, 2 May 2024 14:05:00 -0500 Subject: [PATCH] Skip podspec Swift Search Path validation if only swift file is Package.swift for darwin plugins (#6635) Fix for iOS was added in https://github.com/flutter/packages/pull/6627, but neglected to handle when plugin uses darwin directory. Supplemental fix for https://github.com/flutter/flutter/issues/147548. --- .../tool/lib/src/podspec_check_command.dart | 6 +++++ .../tool/test/podspec_check_command_test.dart | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/script/tool/lib/src/podspec_check_command.dart b/script/tool/lib/src/podspec_check_command.dart index aa3448b0af0d..96df0db31d90 100644 --- a/script/tool/lib/src/podspec_check_command.dart +++ b/script/tool/lib/src/podspec_check_command.dart @@ -169,6 +169,11 @@ class PodspecCheckCommand extends PackageLoopingCommand { .childDirectory(package.directory.basename) .childFile('Package.swift') .path; + final String darwinSwiftPackageManifestPath = package.directory + .childDirectory('darwin') + .childDirectory(package.directory.basename) + .childFile('Package.swift') + .path; return getFilesForPackage(package).any((File entity) { final String relativePath = getRelativePosixPath(entity, from: package.directory); @@ -178,6 +183,7 @@ class PodspecCheckCommand extends PackageLoopingCommand { } final String filePath = entity.path; return filePath != iosSwiftPackageManifestPath && + filePath != darwinSwiftPackageManifestPath && path.extension(filePath) == '.swift'; }); } diff --git a/script/tool/test/podspec_check_command_test.dart b/script/tool/test/podspec_check_command_test.dart index cf5938a4ae42..5ffa4bf2cb13 100644 --- a/script/tool/test/podspec_check_command_test.dart +++ b/script/tool/test/podspec_check_command_test.dart @@ -405,6 +405,28 @@ void main() { )); }); + test( + 'does not require the search paths workaround for darwin Package.swift', + () async { + final RepositoryPackage plugin = createFakePlugin( + 'plugin1', + packagesDir, + extraFiles: ['darwin/plugin1/Package.swift'], + ); + _writeFakePodspec(plugin, 'darwin'); + + final List output = + await runCapturingPrint(runner, ['podspec-check']); + + expect( + output, + containsAllInOrder( + [ + contains('Ran for 1 package(s)'), + ], + )); + }); + test('does not require the search paths workaround for macOS plugins', () async { final RepositoryPackage plugin = createFakePlugin('plugin1', packagesDir,