diff --git a/packages/shorebird_cli/lib/src/commands/patch/patch_ios_command.dart b/packages/shorebird_cli/lib/src/commands/patch/patch_ios_command.dart index 27061baa..8a1e79f4 100644 --- a/packages/shorebird_cli/lib/src/commands/patch/patch_ios_command.dart +++ b/packages/shorebird_cli/lib/src/commands/patch/patch_ios_command.dart @@ -127,14 +127,13 @@ class PatchIosCommand extends ShorebirdCommand 'Detecting release version', ); try { - final pubspec = ShorebirdEnvironment.getPubspecYaml()!; final ipa = _ipaReader.read( p.join( Directory.current.path, 'build', 'ios', 'ipa', - '${pubspec.name}.ipa', + '${getIpaName()}.ipa', ), ); releaseVersion = ipa.versionNumber; diff --git a/packages/shorebird_cli/lib/src/commands/release/release_ios_command.dart b/packages/shorebird_cli/lib/src/commands/release/release_ios_command.dart index 8270430d..ddff83dc 100644 --- a/packages/shorebird_cli/lib/src/commands/release/release_ios_command.dart +++ b/packages/shorebird_cli/lib/src/commands/release/release_ios_command.dart @@ -7,6 +7,7 @@ import 'package:shorebird_cli/src/code_push_client_wrapper.dart'; import 'package:shorebird_cli/src/command.dart'; import 'package:shorebird_cli/src/config/config.dart'; import 'package:shorebird_cli/src/logger.dart'; +import 'package:shorebird_cli/src/shorebird_artifact_mixin.dart'; import 'package:shorebird_cli/src/shorebird_build_mixin.dart'; import 'package:shorebird_cli/src/shorebird_config_mixin.dart'; import 'package:shorebird_cli/src/shorebird_environment.dart'; @@ -17,7 +18,11 @@ import 'package:shorebird_cli/src/shorebird_validation_mixin.dart'; /// Create new app releases for iOS. /// {@endtemplate} class ReleaseIosCommand extends ShorebirdCommand - with ShorebirdBuildMixin, ShorebirdConfigMixin, ShorebirdValidationMixin { + with + ShorebirdBuildMixin, + ShorebirdConfigMixin, + ShorebirdArtifactMixin, + ShorebirdValidationMixin { /// {@macro release_ios_command} ReleaseIosCommand({ super.cache, @@ -89,13 +94,12 @@ make smaller updates to your app. buildProgress.complete(); final releaseVersionProgress = logger.progress('Getting release version'); - final pubspec = ShorebirdEnvironment.getPubspecYaml()!; final ipaPath = p.join( Directory.current.path, 'build', 'ios', 'ipa', - '${pubspec.name}.ipa', + '${getIpaName()}.ipa', ); String releaseVersion; try { diff --git a/packages/shorebird_cli/lib/src/shorebird_artifact_mixin.dart b/packages/shorebird_cli/lib/src/shorebird_artifact_mixin.dart index f8907fa5..9daf0478 100644 --- a/packages/shorebird_cli/lib/src/shorebird_artifact_mixin.dart +++ b/packages/shorebird_cli/lib/src/shorebird_artifact_mixin.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:path/path.dart' as p; +import 'package:propertylistserialization/propertylistserialization.dart'; import 'package:shorebird_cli/src/command.dart'; import 'package:shorebird_cli/src/logger.dart'; @@ -61,6 +62,23 @@ mixin ShorebirdArtifactMixin on ShorebirdCommand { return extractedZipDir; } + /// Finds CFBundleName in the app's Info.plist. The ipa generated by `flutter + /// build ipa` will have this name and an .ipa extension. + String getIpaName() { + final infoPlist = PropertyListSerialization.propertyListWithString( + File( + p.join( + Directory.current.path, + 'ios', + 'Runner', + 'Info.plist', + ), + ).readAsStringSync(), + ) as Map; + + return infoPlist['CFBundleName']! as String; + } + /// Finds the most recently-edited app.dill file in the .dart_tool directory. // TODO(bryanoltman): This is an enormous hack – we don't know that this is // the correct file. diff --git a/packages/shorebird_cli/test/src/commands/patch/patch_ios_command_test.dart b/packages/shorebird_cli/test/src/commands/patch/patch_ios_command_test.dart index b7a2d562..b40c4e33 100644 --- a/packages/shorebird_cli/test/src/commands/patch/patch_ios_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/patch/patch_ios_command_test.dart @@ -61,6 +61,15 @@ void main() { const appDisplayName = 'Test App'; const platformName = 'ios'; const elfAotSnapshotFileName = 'out.aot'; + const infoPlistContent = ''' + + + + + CFBundleName + app_bundle_name + +'''; const pubspecYamlContent = ''' name: example version: $version @@ -117,6 +126,11 @@ flutter: File( p.join(tempDir.path, 'shorebird.yaml'), ).writeAsStringSync('app_id: $appId'); + File( + p.join(tempDir.path, 'ios', 'Runner', 'Info.plist'), + ) + ..createSync(recursive: true) + ..writeAsStringSync(infoPlistContent); return tempDir; } diff --git a/packages/shorebird_cli/test/src/commands/release/release_ios_command_test.dart b/packages/shorebird_cli/test/src/commands/release/release_ios_command_test.dart index 00031e26..f1cdddef 100644 --- a/packages/shorebird_cli/test/src/commands/release/release_ios_command_test.dart +++ b/packages/shorebird_cli/test/src/commands/release/release_ios_command_test.dart @@ -63,7 +63,15 @@ void main() { flutterRevision: flutterRevision, displayName: '1.2.3+1', ); - + const infoPlistContent = ''' + + + + + CFBundleName + app_bundle_name + +'''; const pubspecYamlContent = ''' name: example version: $version @@ -110,7 +118,11 @@ flutter: File( p.join(tempDir.path, 'shorebird.yaml'), ).writeAsStringSync('app_id: $appId'); - + File( + p.join(tempDir.path, 'ios', 'Runner', 'Info.plist'), + ) + ..createSync(recursive: true) + ..writeAsStringSync(infoPlistContent); return tempDir; } @@ -431,7 +443,7 @@ error: exportArchive: No signing certificate "iOS Distribution" found that: stringContainsInOrder( [ 'Your next step is to upload the ipa to App Store Connect.', - 'build/ios/ipa/example.ipa', + 'build/ios/ipa/app_bundle_name.ipa', ], ), ), @@ -467,7 +479,7 @@ flavors: that: stringContainsInOrder( [ 'Your next step is to upload the ipa to App Store Connect.', - 'build/ios/ipa/example.ipa', + 'build/ios/ipa/app_bundle_name.ipa', ], ), ),