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,