Use Xcode build setting PRODUCT_NAME to find app and archive paths (#140242)
1. Instead of getting the `FULL_PRODUCT_NAME` Xcode build setting (`Runner.app`) instead use `PRODUCT_NAME` since most places really want the product name, and the extension stripping wasn't correct when the name contained periods. 2. Don't instruct the user to open the `xcarchive` in Xcode if it doesn't exist. Fixes https://github.com/flutter/flutter/issues/140212
This commit is contained in:
@@ -517,7 +517,14 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
|
||||
|
||||
globals.printError('Encountered error while creating the IPA:');
|
||||
globals.printError(errorMessage.toString());
|
||||
globals.printError('Try distributing the app in Xcode: "open $absoluteArchivePath"');
|
||||
|
||||
final FileSystemEntityType type = globals.fs.typeSync(absoluteArchivePath);
|
||||
globals.printError('Try distributing the app in Xcode:');
|
||||
if (type == FileSystemEntityType.notFound) {
|
||||
globals.printError('open ios/Runner.xcworkspace', indent: 2);
|
||||
} else {
|
||||
globals.printError('open $absoluteArchivePath', indent: 2);
|
||||
}
|
||||
|
||||
// Even though the IPA step didn't succeed, the xcarchive did.
|
||||
// Still count this as success since the user has been instructed about how to
|
||||
|
||||
@@ -108,25 +108,25 @@ abstract class IOSApp extends ApplicationPackage {
|
||||
}
|
||||
|
||||
class BuildableIOSApp extends IOSApp {
|
||||
BuildableIOSApp(this.project, String projectBundleId, String? hostAppBundleName)
|
||||
: _hostAppBundleName = hostAppBundleName,
|
||||
BuildableIOSApp(this.project, String projectBundleId, String? productName)
|
||||
: _appProductName = productName,
|
||||
super(projectBundleId: projectBundleId);
|
||||
|
||||
static Future<BuildableIOSApp?> fromProject(IosProject project, BuildInfo? buildInfo) async {
|
||||
final String? hostAppBundleName = await project.hostAppBundleName(buildInfo);
|
||||
final String? productName = await project.productName(buildInfo);
|
||||
final String? projectBundleId = await project.productBundleIdentifier(buildInfo);
|
||||
if (projectBundleId != null) {
|
||||
return BuildableIOSApp(project, projectBundleId, hostAppBundleName);
|
||||
return BuildableIOSApp(project, projectBundleId, productName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
final IosProject project;
|
||||
|
||||
final String? _hostAppBundleName;
|
||||
final String? _appProductName;
|
||||
|
||||
@override
|
||||
String? get name => _hostAppBundleName;
|
||||
String? get name => _appProductName;
|
||||
|
||||
@override
|
||||
String get simulatorBundlePath => _buildAppPath('iphonesimulator');
|
||||
@@ -141,16 +141,15 @@ class BuildableIOSApp extends IOSApp {
|
||||
// not a top-level output directory.
|
||||
// Specifying `build/ios/archive/Runner` will result in `build/ios/archive/Runner.xcarchive`.
|
||||
String get archiveBundlePath => globals.fs.path.join(getIosBuildDirectory(), 'archive',
|
||||
_hostAppBundleName == null ? 'Runner' : globals.fs.path.withoutExtension(_hostAppBundleName));
|
||||
_appProductName ?? 'Runner');
|
||||
|
||||
// The output xcarchive bundle path `build/ios/archive/Runner.xcarchive`.
|
||||
String get archiveBundleOutputPath =>
|
||||
globals.fs.path.setExtension(archiveBundlePath, '.xcarchive');
|
||||
String get archiveBundleOutputPath => '$archiveBundlePath.xcarchive';
|
||||
|
||||
String get builtInfoPlistPathAfterArchive => globals.fs.path.join(archiveBundleOutputPath,
|
||||
'Products',
|
||||
'Applications',
|
||||
_hostAppBundleName ?? 'Runner.app',
|
||||
_appProductName != null ? '$_appProductName.app' : 'Runner.app',
|
||||
'Info.plist');
|
||||
|
||||
String get projectAppIconDirName => _projectImageAssetDirName(_appIconAsset);
|
||||
@@ -173,7 +172,7 @@ class BuildableIOSApp extends IOSApp {
|
||||
globals.fs.path.join(getIosBuildDirectory(), 'ipa');
|
||||
|
||||
String _buildAppPath(String type) {
|
||||
return globals.fs.path.join(getIosBuildDirectory(), type, _hostAppBundleName);
|
||||
return globals.fs.path.join(getIosBuildDirectory(), type, '$_appProductName.app');
|
||||
}
|
||||
|
||||
String _projectImageAssetDirName(String asset)
|
||||
|
||||
@@ -174,7 +174,7 @@ class IosProject extends XcodeBasedProject {
|
||||
static const String kProductBundleIdKey = 'PRODUCT_BUNDLE_IDENTIFIER';
|
||||
static const String kTeamIdKey = 'DEVELOPMENT_TEAM';
|
||||
static const String kEntitlementFilePathKey = 'CODE_SIGN_ENTITLEMENTS';
|
||||
static const String kHostAppBundleNameKey = 'FULL_PRODUCT_NAME';
|
||||
static const String kProductNameKey = 'PRODUCT_NAME';
|
||||
|
||||
static final RegExp _productBundleIdPattern = RegExp('^\\s*$kProductBundleIdKey\\s*=\\s*(["\']?)(.*?)\\1;\\s*\$');
|
||||
static const String _kProductBundleIdVariable = '\$($kProductBundleIdKey)';
|
||||
@@ -397,16 +397,16 @@ class IosProject extends XcodeBasedProject {
|
||||
return const <String>[];
|
||||
}
|
||||
|
||||
/// The bundle name of the host app, `My App.app`.
|
||||
Future<String?> hostAppBundleName(BuildInfo? buildInfo) async {
|
||||
/// The product name of the app, `My App`.
|
||||
Future<String?> productName(BuildInfo? buildInfo) async {
|
||||
if (!existsSync()) {
|
||||
return null;
|
||||
}
|
||||
return _hostAppBundleName ??= await _parseHostAppBundleName(buildInfo);
|
||||
return _productName ??= await _parseProductName(buildInfo);
|
||||
}
|
||||
String? _hostAppBundleName;
|
||||
String? _productName;
|
||||
|
||||
Future<String> _parseHostAppBundleName(BuildInfo? buildInfo) async {
|
||||
Future<String> _parseProductName(BuildInfo? buildInfo) async {
|
||||
// The product name and bundle name are derived from the display name, which the user
|
||||
// is instructed to change in Xcode as part of deploying to the App Store.
|
||||
// https://flutter.dev/to/xcode-name-config
|
||||
@@ -415,13 +415,13 @@ class IosProject extends XcodeBasedProject {
|
||||
if (globals.xcodeProjectInterpreter?.isInstalled ?? false) {
|
||||
final Map<String, String>? xcodeBuildSettings = await buildSettingsForBuildInfo(buildInfo);
|
||||
if (xcodeBuildSettings != null) {
|
||||
productName = xcodeBuildSettings[kHostAppBundleNameKey];
|
||||
productName = xcodeBuildSettings[kProductNameKey];
|
||||
}
|
||||
}
|
||||
if (productName == null) {
|
||||
globals.printTrace('$kHostAppBundleNameKey not present, defaulting to $hostAppProjectName');
|
||||
globals.printTrace('$kProductNameKey not present, defaulting to $hostAppProjectName');
|
||||
}
|
||||
return productName ?? '${XcodeBasedProject._defaultHostAppName}.app';
|
||||
return productName ?? XcodeBasedProject._defaultHostAppName;
|
||||
}
|
||||
|
||||
/// The build settings for the host app of this project, as a detached map.
|
||||
|
||||
Reference in New Issue
Block a user