From 51606f99a49eebe29357995eb9391feaf3cfad5d Mon Sep 17 00:00:00 2001 From: LouiseHsu Date: Thu, 8 Aug 2024 09:07:27 -0700 Subject: [PATCH] Fix `flutter build ipa --export-method` not accepting `enterprise` flag (#153047) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When implementing the fix for https://github.com/flutter/flutter/issues/149369, I missed accounting for the `enterprise` flag for `flutter build ipa` 😬 Fixes https://github.com/flutter/flutter/issues/153000 --- .../lib/src/commands/build_ios.dart | 2 - .../hermetic/build_ipa_test.dart | 74 +++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/commands/build_ios.dart b/packages/flutter_tools/lib/src/commands/build_ios.dart index 366f6f4f7f..3401776c52 100644 --- a/packages/flutter_tools/lib/src/commands/build_ios.dart +++ b/packages/flutter_tools/lib/src/commands/build_ios.dart @@ -599,8 +599,6 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand { return 'release-testing'; case 'development': return 'debugging'; - default: - throwToolExit('Encountered invalid export-method input.'); } } return method; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_ipa_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_ipa_test.dart index 68de868604..5eb4b8ed68 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_ipa_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_ipa_test.dart @@ -554,6 +554,80 @@ void main() { XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(version: Version(15, 4, null)), }); + testUsingContext('ipa build accepts "enterprise" export method when on Xcode versions <= 15.3', () async { + final BuildCommand command = BuildCommand( + artifacts: artifacts, + androidSdk: FakeAndroidSdk(), + buildSystem: TestBuildSystem.all(BuildResult(success: true)), + logger: logger, + fileSystem: fileSystem, + processUtils: processUtils, + osUtils: FakeOperatingSystemUtils(), + ); + fakeProcessManager.addCommands([ + xattrCommand, + setUpFakeXcodeBuildHandler(), + exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist), + ]); + createMinimalMockProjectFiles(); + await createTestCommandRunner(command).run( + const ['build', 'ipa','--export-method', 'enterprise', '--no-pub'] + ); + expect(logger.statusText, contains('Building enterprise IPA')); + }, overrides: { + FileSystem: () => fileSystem, + Logger: () => logger, + ProcessManager: () => fakeProcessManager, + Platform: () => macosPlatform, + XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(version: Version(15, 3, null)), + }); + + testUsingContext('ipa build accepts "enterprise" export method when on Xcode versions > 15.3', () async { + final File cachedExportOptionsPlist = fileSystem.file('/CachedExportOptions.plist'); + final BuildCommand command = BuildCommand( + artifacts: artifacts, + androidSdk: FakeAndroidSdk(), + buildSystem: TestBuildSystem.all(BuildResult(success: true)), + logger: logger, + fileSystem: fileSystem, + processUtils: processUtils, + osUtils: FakeOperatingSystemUtils(), + ); + fakeProcessManager.addCommands([ + xattrCommand, + setUpFakeXcodeBuildHandler(), + exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist), + ]); + createMinimalMockProjectFiles(); + await createTestCommandRunner(command).run( + const ['build', 'ipa','--export-method', 'enterprise', '--no-pub'] + ); + + const String expectedIpaPlistContents = ''' + + + + + method + enterprise + uploadBitcode + + + +'''; + + final String actualIpaPlistContents = fileSystem.file(cachedExportOptionsPlist).readAsStringSync(); + + expect(actualIpaPlistContents, expectedIpaPlistContents); + expect(logger.statusText, contains('Building enterprise IPA')); + }, overrides: { + FileSystem: () => fileSystem, + Logger: () => logger, + ProcessManager: () => fakeProcessManager, + Platform: () => macosPlatform, + XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(version: Version(15, 4, null)), + }); + testUsingContext('ipa build accepts legacy methods when on Xcode versions <= 15.3', () async { final BuildCommand command = BuildCommand( artifacts: artifacts,