From 8fe197d1fcbbd09ff7289b925c7ed4d99338feda Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Tue, 11 Jun 2024 10:28:56 -0500 Subject: [PATCH 1/2] feat(shorebird_cli): require Flutter 3.22.2 for iOS --- .../lib/src/commands/patch/ios_patcher.dart | 17 ++++++-- .../shorebird_cli/lib/src/platform/ios.dart | 2 +- .../src/commands/patch/ios_patcher_test.dart | 39 ++++++++++++++++++- 3 files changed, 52 insertions(+), 6 deletions(-) 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..956790a8d 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,14 +268,48 @@ void main() { }); group('buildPatchArtifact', () { - const flutterVersionAndRevision = '3.10.6 (83305b5088)'; - + const flutterVersionAndRevision = '3.22.2 (83305b5088)'; setUp(() { when( () => shorebirdFlutter.getVersionAndRevision(), ).thenAnswer((_) async => flutterVersionAndRevision); }); + 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', () { setUp(() { when(() => ios.exportOptionsPlistFromArgs(any())).thenThrow( From 3715b36242ccb23f2df86e647ed9beb3c369053d Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Tue, 11 Jun 2024 11:03:56 -0500 Subject: [PATCH 2/2] fix tests --- .../test/src/commands/patch/ios_patcher_test.dart | 3 +++ 1 file changed, 3 insertions(+) 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 956790a8d..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 @@ -273,6 +273,9 @@ void main() { when( () => shorebirdFlutter.getVersionAndRevision(), ).thenAnswer((_) async => flutterVersionAndRevision); + when( + () => shorebirdFlutter.getVersion(), + ).thenAnswer((_) async => Version(3, 22, 2)); }); group('when specified flutter version is less than minimum', () {