diff --git a/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart b/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart index c42df1b60..12de77e87 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart @@ -90,10 +90,21 @@ class IosPatcher extends Patcher { try { final shouldCodesign = argResults['codesign'] == true; - final flutterVersionString = - await shorebirdFlutter.getVersionAndRevision(); + final (flutterVersionAndRevision, flutterVersion) = await ( + shorebirdFlutter.getVersionAndRevision(), + shorebirdFlutter.getVersion(), + ).wait; + + if ((flutterVersion ?? minimumSupportedIosFlutterVersion) < + minimumSupportedIosFlutterVersion) { + logger.err( + '''iOS patches are not supported with Flutter versions older than $minimumSupportedIosFlutterVersion.''', + ); + exit(ExitCode.software.code); + } + final buildProgress = logger.progress( - 'Building patch with Flutter $flutterVersionString', + 'Building patch with Flutter $flutterVersionAndRevision', ); final IpaBuildResult ipaBuildResult; try { diff --git a/packages/shorebird_cli/lib/src/platform/ios.dart b/packages/shorebird_cli/lib/src/platform/ios.dart index 5b3ee61b3..39082c808 100644 --- a/packages/shorebird_cli/lib/src/platform/ios.dart +++ b/packages/shorebird_cli/lib/src/platform/ios.dart @@ -52,7 +52,7 @@ class InvalidExportOptionsPlistException implements Exception { } /// The minimum allowed Flutter version for creating iOS releases. -final minimumSupportedIosFlutterVersion = Version(3, 19, 5); +final minimumSupportedIosFlutterVersion = Version(3, 22, 2); /// A reference to a [Ios] instance. final iosRef = create(Ios.new); diff --git a/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart b/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart index a870eee47..7d61e4c2b 100644 --- a/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/ios_patcher_test.dart @@ -3,6 +3,7 @@ import 'package:mason_logger/mason_logger.dart'; import 'package:mocktail/mocktail.dart'; import 'package:path/path.dart' as p; import 'package:platform/platform.dart'; +import 'package:pub_semver/pub_semver.dart'; import 'package:scoped_deps/scoped_deps.dart'; import 'package:shorebird_cli/src/archive_analysis/archive_analysis.dart'; import 'package:shorebird_cli/src/artifact_builder.dart'; @@ -267,12 +268,49 @@ void main() { }); group('buildPatchArtifact', () { - const flutterVersionAndRevision = '3.10.6 (83305b5088)'; - + const flutterVersionAndRevision = '3.22.2 (83305b5088)'; setUp(() { when( () => shorebirdFlutter.getVersionAndRevision(), ).thenAnswer((_) async => flutterVersionAndRevision); + when( + () => shorebirdFlutter.getVersion(), + ).thenAnswer((_) async => Version(3, 22, 2)); + }); + + group('when specified flutter version is less than minimum', () { + setUp(() { + when( + () => shorebirdValidator.validatePreconditions( + checkUserIsAuthenticated: any( + named: 'checkUserIsAuthenticated', + ), + checkShorebirdInitialized: any( + named: 'checkShorebirdInitialized', + ), + validators: any(named: 'validators'), + supportedOperatingSystems: any( + named: 'supportedOperatingSystems', + ), + ), + ).thenAnswer((_) async {}); + when( + () => shorebirdFlutter.getVersion(), + ).thenAnswer((_) async => Version(3, 0, 0)); + }); + + test('logs error and exits with code 70', () async { + await expectLater( + () => runWithOverrides(patcher.buildPatchArtifact), + exitsWithCode(ExitCode.software), + ); + + verify( + () => logger.err( + '''iOS patches are not supported with Flutter versions older than $minimumSupportedIosFlutterVersion.''', + ), + ).called(1); + }); }); group('when exportOptionsPlist fails', () {