Skip to content

Commit 4659b0c

Browse files
authored
refactored cli tool ipa method name to support --export-options-plist (flutter#138555)
This PR changes the way the IPA method is read in the run command for `build ipa` command. If export options plist argument is provided it takes method name from plist, otherwise it uses the method name from export method argument. *List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.* fixes [flutter#122179](flutter#122179)
1 parent f8b9748 commit 4659b0c

File tree

2 files changed

+74
-3
lines changed

2 files changed

+74
-3
lines changed

packages/flutter_tools/lib/src/commands/build_ios.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,15 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
463463
final String relativeOutputPath = app.ipaOutputPath;
464464
final String absoluteOutputPath = globals.fs.path.absolute(relativeOutputPath);
465465
final String absoluteArchivePath = globals.fs.path.absolute(app.archiveBundleOutputPath);
466-
final String exportMethod = stringArg('export-method')!;
467-
final bool isAppStoreUpload = exportMethod == 'app-store';
466+
String? exportOptions = exportOptionsPlist;
467+
String? exportMethod = exportOptions != null ?
468+
globals.plistParser.getValueFromFile<String?>(exportOptions, 'method') : null;
469+
exportMethod ??= stringArg('export-method')!;
470+
final bool isAppStoreUpload = exportMethod == 'app-store';
468471
File? generatedExportPlist;
469472
try {
470473
final String exportMethodDisplayName = isAppStoreUpload ? 'App Store' : exportMethod;
471474
status = globals.logger.startProgress('Building $exportMethodDisplayName IPA...');
472-
String? exportOptions = exportOptionsPlist;
473475
if (exportOptions == null) {
474476
generatedExportPlist = _createExportPlist();
475477
exportOptions = generatedExportPlist.path;

packages/flutter_tools/test/commands.shard/hermetic/build_ipa_test.dart

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,75 @@ void main() {
379379
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
380380
});
381381

382+
testUsingContext('ipa build reports method from --export-method when used', () async {
383+
final BuildCommand command = BuildCommand(
384+
artifacts: artifacts,
385+
androidSdk: FakeAndroidSdk(),
386+
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
387+
logger: logger,
388+
fileSystem: fileSystem,
389+
processUtils: processUtils,
390+
osUtils: FakeOperatingSystemUtils(),
391+
);
392+
fakeProcessManager.addCommands(<FakeCommand>[
393+
xattrCommand,
394+
setUpFakeXcodeBuildHandler(),
395+
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
396+
]);
397+
createMinimalMockProjectFiles();
398+
await createTestCommandRunner(command).run(
399+
const <String>['build', 'ipa','--export-method', 'ad-hoc', '--no-pub']
400+
);
401+
402+
expect(logger.statusText, contains('build/ios/archive/Runner.xcarchive'));
403+
expect(logger.statusText, contains('Building ad-hoc IPA'));
404+
}, overrides: <Type, Generator>{
405+
FileSystem: () => fileSystem,
406+
Logger: () => logger,
407+
ProcessManager: () => fakeProcessManager,
408+
Platform: () => macosPlatform,
409+
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
410+
});
411+
412+
testUsingContext('ipa build reports method from --export-options-plist when used', () async {
413+
final File exportOptions = fileSystem.file('/ExportOptions.plist')
414+
..createSync();
415+
createMinimalMockProjectFiles();
416+
417+
plistUtils.fileContents[exportOptions.path] = <String,String>{
418+
'CFBundleIdentifier': 'io.flutter.someProject',
419+
'method': 'enterprise'
420+
};
421+
422+
fakeProcessManager.addCommands(<FakeCommand>[
423+
xattrCommand,
424+
setUpFakeXcodeBuildHandler(),
425+
exportArchiveCommand(exportOptionsPlist: exportOptions.path),
426+
]);
427+
final BuildCommand command = BuildCommand(
428+
artifacts: artifacts,
429+
androidSdk: FakeAndroidSdk(),
430+
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
431+
logger: logger,
432+
fileSystem: fileSystem,
433+
processUtils: processUtils,
434+
osUtils: FakeOperatingSystemUtils(),
435+
);
436+
await createTestCommandRunner(command).run(
437+
<String>['build', 'ipa', '--export-options-plist', exportOptions.path, '--no-pub']
438+
);
439+
440+
expect(logger.statusText, contains('build/ios/archive/Runner.xcarchive'));
441+
expect(logger.statusText, contains('Building enterprise IPA'));
442+
}, overrides: <Type, Generator>{
443+
FileSystem: () => fileSystem,
444+
Logger: () => logger,
445+
ProcessManager: () => fakeProcessManager,
446+
Platform: () => macosPlatform,
447+
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
448+
PlistParser: () => plistUtils,
449+
});
450+
382451
testUsingContext('ipa build reports when IPA fails', () async {
383452
final BuildCommand command = BuildCommand(
384453
artifacts: artifacts,

0 commit comments

Comments
 (0)