Skip to content

Commit

Permalink
feat(shorebird_cli): require Flutter >=3.22.2 for iOS (#2218)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Jun 11, 2024
1 parent 44cab5a commit ea06964
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 6 deletions.
17 changes: 14 additions & 3 deletions packages/shorebird_cli/lib/src/commands/patch/ios_patcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/shorebird_cli/lib/src/platform/ios.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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', () {
Expand Down

0 comments on commit ea06964

Please sign in to comment.