Check Xcode build setting FULL_PRODUCT_NAME for bundle name (#55799)

This commit is contained in:
Jenn Magder
2020-05-04 11:31:08 -07:00
committed by GitHub
parent 741ef91961
commit c8c55b4098
14 changed files with 319 additions and 222 deletions

View File

@@ -357,18 +357,22 @@ abstract class IOSApp extends ApplicationPackage {
}
class BuildableIOSApp extends IOSApp {
BuildableIOSApp(this.project, String projectBundleId)
: super(projectBundleId: projectBundleId);
BuildableIOSApp(this.project, String projectBundleId, String hostAppBundleName)
: _hostAppBundleName = hostAppBundleName,
super(projectBundleId: projectBundleId);
static Future<BuildableIOSApp> fromProject(IosProject project) async {
final String projectBundleId = await project.productBundleIdentifier;
return BuildableIOSApp(project, projectBundleId);
final String hostAppBundleName = await project.hostAppBundleName;
return BuildableIOSApp(project, projectBundleId, hostAppBundleName);
}
final IosProject project;
final String _hostAppBundleName;
@override
String get name => project.hostAppBundleName;
String get name => _hostAppBundleName;
@override
String get simulatorBundlePath => _buildAppPath('iphonesimulator');
@@ -377,7 +381,7 @@ class BuildableIOSApp extends IOSApp {
String get deviceBundlePath => _buildAppPath('iphoneos');
String _buildAppPath(String type) {
return globals.fs.path.join(getIosBuildDirectory(), type, name);
return globals.fs.path.join(getIosBuildDirectory(), type, _hostAppBundleName);
}
}

View File

@@ -632,7 +632,7 @@ bool upgradePbxProjWithFlutterAssets(IosProject project, Logger logger) {
final Match match = oldAssets.firstMatch(line);
if (match != null) {
if (printedStatuses.add(match.group(1))) {
logger.printStatus('Removing obsolete reference to ${match.group(1)} from ${project.hostAppBundleName}');
logger.printStatus('Removing obsolete reference to ${match.group(1)} from ${project.xcodeProject?.basename}');
}
} else {
buffer.writeln(line);

View File

@@ -685,7 +685,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
// Match the log prefix (in order to shorten it):
// * Xcode 8: Sep 13 15:28:51 cbracken-macpro localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/
// * Xcode 9: 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/
static final RegExp _mapRegex = RegExp(r'\S+ +\S+ +\S+ +(\S+ +)?(\S+)\[\d+\]\)?: (\(.*?\))? *(.*)$');
static final RegExp _mapRegex = RegExp(r'\S+ +\S+ +(?:\S+) (.+?(?=\[))\[\d+\]\)?: (\(.*?\))? *(.*)$');
// Jan 31 19:23:28 --- last message repeated 1 time ---
static final RegExp _lastMessageSingleRegex = RegExp(r'\S+ +\S+ +\S+ --- last message repeated 1 time ---$');
@@ -700,12 +700,16 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
String _filterDeviceLine(String string) {
final Match match = _mapRegex.matchAsPrefix(string);
if (match != null) {
final String category = match.group(2);
final String tag = match.group(3);
final String content = match.group(4);
// Filter out non-Flutter originated noise from the engine.
if (_appName != null && category != _appName) {
// The category contains the text between the date and the PID. Depending on which version of iOS being run,
// it can contain "hostname App Name" or just "App Name".
final String category = match.group(1);
final String tag = match.group(2);
final String content = match.group(3);
// Filter out log lines from an app other than this one (category doesn't match the app name).
// If the hostname is included in the category, check that it doesn't end with the app name.
if (_appName != null && !category.endsWith(_appName)) {
return null;
}
@@ -725,7 +729,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader {
if (_appName == null) {
return '$category: $content';
} else if (category == _appName) {
} else if (category == _appName || category.endsWith(' $_appName')) {
return content;
}

View File

@@ -341,7 +341,7 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
static final RegExp _productBundleIdPattern = RegExp(r'''^\s*PRODUCT_BUNDLE_IDENTIFIER\s*=\s*(["']?)(.*?)\1;\s*$''');
static const String _productBundleIdVariable = r'$(PRODUCT_BUNDLE_IDENTIFIER)';
static const String _hostAppBundleName = 'Runner';
static const String _hostAppProjectName = 'Runner';
Directory get ephemeralDirectory => parent.directory.childDirectory('.ios');
Directory get _editableDirectory => parent.directory.childDirectory('ios');
@@ -362,9 +362,6 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
/// a Flutter module with an editable host app.
Directory get _flutterLibRoot => isModule ? ephemeralDirectory : _editableDirectory;
/// The bundle name of the host app, `Runner.app`.
String get hostAppBundleName => '$_hostAppBundleName.app';
/// True, if the parent Flutter project is a module project.
bool get isModule => parent.isModule;
@@ -387,19 +384,19 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
File get podManifestLock => hostAppRoot.childDirectory('Pods').childFile('Manifest.lock');
/// The default 'Info.plist' file of the host app. The developer can change this location in Xcode.
File get defaultHostInfoPlist => hostAppRoot.childDirectory(_hostAppBundleName).childFile('Info.plist');
File get defaultHostInfoPlist => hostAppRoot.childDirectory(_hostAppProjectName).childFile('Info.plist');
@override
Directory get symlinks => _flutterLibRoot.childDirectory('.symlinks');
@override
Directory get xcodeProject => hostAppRoot.childDirectory('$_hostAppBundleName.xcodeproj');
Directory get xcodeProject => hostAppRoot.childDirectory('$_hostAppProjectName.xcodeproj');
@override
File get xcodeProjectInfoFile => xcodeProject.childFile('project.pbxproj');
@override
Directory get xcodeWorkspace => hostAppRoot.childDirectory('$_hostAppBundleName.xcworkspace');
Directory get xcodeWorkspace => hostAppRoot.childDirectory('$_hostAppProjectName.xcworkspace');
/// Xcode workspace shared data directory for the host app.
Directory get xcodeWorkspaceSharedData => xcodeWorkspace.childDirectory('xcshareddata');
@@ -414,7 +411,11 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
/// The product bundle identifier of the host app, or null if not set or if
/// iOS tooling needed to read it is not installed.
Future<String> get productBundleIdentifier async {
Future<String> get productBundleIdentifier async =>
_productBundleIdentifier ??= await _parseProductBundleIdentifier();
String _productBundleIdentifier;
Future<String> _parseProductBundleIdentifier() async {
String fromPlist;
final File defaultInfoPlist = defaultHostInfoPlist;
// Users can change the location of the Info.plist.
@@ -456,28 +457,51 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
return null;
}
/// The bundle name of the host app, `My App.app`.
Future<String> get hostAppBundleName async =>
_hostAppBundleName ??= await _parseHostAppBundleName();
String _hostAppBundleName;
Future<String> _parseHostAppBundleName() 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/docs/deployment/ios#review-xcode-project-settings
// The only source of truth for the name is Xcode's interpretation of the build settings.
String productName;
if (globals.xcodeProjectInterpreter.isInstalled) {
final Map<String, String> xcodeBuildSettings = await buildSettings;
if (xcodeBuildSettings != null) {
productName = xcodeBuildSettings['FULL_PRODUCT_NAME'];
}
}
if (productName == null) {
globals.printTrace('FULL_PRODUCT_NAME not present, defaulting to $_hostAppProjectName');
}
return productName ?? '$_hostAppProjectName.app';
}
/// The build settings for the host app of this project, as a detached map.
///
/// Returns null, if iOS tooling is unavailable.
Future<Map<String, String>> get buildSettings async {
Future<Map<String, String>> get buildSettings async =>
_buildSettings ??= await _xcodeProjectBuildSettings();
Map<String, String> _buildSettings;
Future<Map<String, String>> _xcodeProjectBuildSettings() async {
if (!globals.xcodeProjectInterpreter.isInstalled) {
return null;
}
Map<String, String> buildSettings = _buildSettings;
buildSettings ??= await globals.xcodeProjectInterpreter.getBuildSettings(
final Map<String, String> buildSettings = await globals.xcodeProjectInterpreter.getBuildSettings(
xcodeProject.path,
_hostAppBundleName,
_hostAppProjectName,
);
if (buildSettings != null && buildSettings.isNotEmpty) {
// No timeouts, flakes, or errors.
_buildSettings = buildSettings;
return buildSettings;
}
return null;
}
Map<String, String> _buildSettings;
Future<void> ensureReadyForPlatformSpecificTooling() async {
await _regenerateFromTemplateIfNeeded();
if (!_flutterLibRoot.existsSync()) {
@@ -614,7 +638,7 @@ class IosProject extends FlutterProjectPlatform implements XcodeBasedProject {
? _flutterLibRoot
.childDirectory('Flutter')
.childDirectory('FlutterPluginRegistrant')
: hostAppRoot.childDirectory(_hostAppBundleName);
: hostAppRoot.childDirectory(_hostAppProjectName);
}
Future<void> _overwriteFromTemplate(String path, Directory target) async {
@@ -888,7 +912,7 @@ class MacOSProject extends FlutterProjectPlatform implements XcodeBasedProject {
@override
String get pluginConfigKey => MacOSPlugin.kConfigKey;
static const String _hostAppBundleName = 'Runner';
static const String _hostAppProjectName = 'Runner';
@override
bool existsSync() => _macOSDirectory.existsSync();
@@ -932,13 +956,13 @@ class MacOSProject extends FlutterProjectPlatform implements XcodeBasedProject {
File get podManifestLock => _macOSDirectory.childDirectory('Pods').childFile('Manifest.lock');
@override
Directory get xcodeProject => _macOSDirectory.childDirectory('$_hostAppBundleName.xcodeproj');
Directory get xcodeProject => _macOSDirectory.childDirectory('$_hostAppProjectName.xcodeproj');
@override
File get xcodeProjectInfoFile => xcodeProject.childFile('project.pbxproj');
@override
Directory get xcodeWorkspace => _macOSDirectory.childDirectory('$_hostAppBundleName.xcworkspace');
Directory get xcodeWorkspace => _macOSDirectory.childDirectory('$_hostAppProjectName.xcworkspace');
@override
Directory get symlinks => ephemeralDirectory.childDirectory('.symlinks');