diff --git a/packages/shorebird_cli/lib/src/commands/release/release_ios_framework_command.dart b/packages/shorebird_cli/lib/src/commands/release/release_ios_framework_command.dart index 9625ae08..eee9418a 100644 --- a/packages/shorebird_cli/lib/src/commands/release/release_ios_framework_command.dart +++ b/packages/shorebird_cli/lib/src/commands/release/release_ios_framework_command.dart @@ -26,6 +26,15 @@ The version of the associated release (e.g. "1.0.0"). This should be the version of the iOS app that is using this module.''', mandatory: true, ) + ..addOption( + 'target', + abbr: 't', + help: 'The main entrypoint file of the module.', + ) + ..addOption( + 'flavor', + help: 'The product flavor to use when building the module.', + ) ..addFlag( 'force', abbr: 'f', @@ -61,9 +70,11 @@ of the iOS app that is using this module.''', showiOSStatusWarning(); const releasePlatform = ReleasePlatform.ios; + final flavor = results['flavor'] as String?; + final target = results['target'] as String?; final releaseVersion = results['release-version'] as String; final shorebirdYaml = ShorebirdEnvironment.getShorebirdYaml()!; - final appId = shorebirdYaml.getAppId(); + final appId = shorebirdYaml.getAppId(flavor: flavor); final app = await codePushClientWrapper.getApp(appId: appId); final existingRelease = await codePushClientWrapper.maybeGetRelease( @@ -80,7 +91,7 @@ of the iOS app that is using this module.''', final buildProgress = logger.progress('Building iOS framework'); try { - await buildIosFramework(); + await buildIosFramework(flavor: flavor, target: target); } catch (error) { buildProgress.fail('Failed to build iOS framework: $error'); return ExitCode.software.code; @@ -90,8 +101,7 @@ of the iOS app that is using this module.''', final summary = [ '''šŸ“± App: ${lightCyan.wrap(app.displayName)} ${lightCyan.wrap('($appId)')}''', - // TODO(felangel): uncomment once flavor support is added. - // if (flavor != null) 'šŸ§ Flavor: ${lightCyan.wrap(flavor)}', + if (flavor != null) 'šŸ§ Flavor: ${lightCyan.wrap(flavor)}', 'šŸ“¦ Release Version: ${lightCyan.wrap(releaseVersion)}', '''šŸ•¹ļø Platform: ${lightCyan.wrap(releasePlatform.name)}''', ]; diff --git a/packages/shorebird_cli/lib/src/shorebird_build_mixin.dart b/packages/shorebird_cli/lib/src/shorebird_build_mixin.dart index a42a002a..3e3e4924 100644 --- a/packages/shorebird_cli/lib/src/shorebird_build_mixin.dart +++ b/packages/shorebird_cli/lib/src/shorebird_build_mixin.dart @@ -209,13 +209,18 @@ mixin ShorebirdBuildMixin on ShorebirdCommand { } /// Builds a release iOS framework (.xcframework) for the current project. - Future buildIosFramework() async { + Future buildIosFramework({ + String? flavor, + String? target, + }) async { const executable = 'flutter'; final arguments = [ 'build', 'ios-framework', '--no-debug', '--no-profile', + if (flavor != null) '--flavor=$flavor', + if (target != null) '--target=$target', ...results.rest, ]; diff --git a/packages/shorebird_cli/test/src/commands/release/release_ios_framework_command_test.dart b/packages/shorebird_cli/test/src/commands/release/release_ios_framework_command_test.dart index 34943c81..28507ab9 100644 --- a/packages/shorebird_cli/test/src/commands/release/release_ios_framework_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/release/release_ios_framework_command_test.dart @@ -447,5 +447,75 @@ flutter: ).called(1); expect(exitCode, ExitCode.success.code); }); + + test( + 'succeeds when release is successful ' + 'with flavors and target', () async { + const flavor = 'development'; + final target = p.join('lib', 'main_development.dart'); + when(() => argResults['flavor']).thenReturn(flavor); + when(() => argResults['target']).thenReturn(target); + final tempDir = setUpTempDir(); + File( + p.join(tempDir.path, 'shorebird.yaml'), + ).writeAsStringSync(''' +app_id: productionAppId +flavors: + development: $appId'''); + + final exitCode = await IOOverrides.runZoned( + () => runWithOverrides(command.run), + getCurrentDirectory: () => tempDir, + ); + final arguments = [ + 'build', + 'ios-framework', + '--no-debug', + '--no-profile', + '--flavor=$flavor', + '--target=$target', + ]; + verify( + () => shorebirdProcess.run('flutter', arguments, runInShell: true), + ).called(1); + verify( + () => logger.info( + any(that: contains('šŸ§ Flavor: ${lightCyan.wrap(flavor)}')), + ), + ).called(1); + verify(() => logger.success('\nāœ… Published Release!')).called(1); + verify( + () => logger.info( + any( + that: stringContainsInOrder( + [ + 'Your next step is to include the .xcframework files in', + '/build/ios/framework/Release', + 'in your iOS app.' + ], + ), + ), + ), + ).called(1); + verify( + () => codePushClientWrapper.createIosFrameworkReleaseArtifacts( + appId: appId, + releaseId: release.id, + appFrameworkPath: any( + named: 'appFrameworkPath', + that: endsWith('build/ios/framework/Release/App.xcframework'), + ), + ), + ).called(1); + verify( + () => codePushClientWrapper.updateReleaseStatus( + appId: appId, + releaseId: release.id, + platform: releasePlatform, + status: ReleaseStatus.active, + ), + ).called(1); + expect(exitCode, ExitCode.success.code); + }); }); }