Fix flutter build ipa --export-method not accepting enterprise flag (#153047)

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
This commit is contained in:
LouiseHsu 2024-08-08 09:07:27 -07:00 committed by GitHub
parent b6cd31e6b5
commit 51606f99a4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 74 additions and 2 deletions

View File

@ -599,8 +599,6 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
return 'release-testing';
case 'development':
return 'debugging';
default:
throwToolExit('Encountered invalid export-method input.');
}
}
return method;

View File

@ -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(<FakeCommand>[
xattrCommand,
setUpFakeXcodeBuildHandler(),
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
]);
createMinimalMockProjectFiles();
await createTestCommandRunner(command).run(
const <String>['build', 'ipa','--export-method', 'enterprise', '--no-pub']
);
expect(logger.statusText, contains('Building enterprise IPA'));
}, overrides: <Type, Generator>{
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(<FakeCommand>[
xattrCommand,
setUpFakeXcodeBuildHandler(),
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist, cachePlist: cachedExportOptionsPlist),
]);
createMinimalMockProjectFiles();
await createTestCommandRunner(command).run(
const <String>['build', 'ipa','--export-method', 'enterprise', '--no-pub']
);
const String expectedIpaPlistContents = '''
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>enterprise</string>
<key>uploadBitcode</key>
<false/>
</dict>
</plist>
''';
final String actualIpaPlistContents = fileSystem.file(cachedExportOptionsPlist).readAsStringSync();
expect(actualIpaPlistContents, expectedIpaPlistContents);
expect(logger.statusText, contains('Building enterprise IPA'));
}, overrides: <Type, Generator>{
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,