Check Xcode build setting FULL_PRODUCT_NAME for the name of the built app during flutter run (#46928)
This commit is contained in:
committed by
Flutter GitHub Bot
parent
a15a81be21
commit
e54e301d50
@@ -358,18 +358,21 @@ abstract class IOSApp extends ApplicationPackage {
|
||||
}
|
||||
|
||||
class BuildableIOSApp extends IOSApp {
|
||||
BuildableIOSApp(this.project, String projectBundleId)
|
||||
BuildableIOSApp(this.project, String projectBundleId, this._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');
|
||||
@@ -378,7 +381,7 @@ class BuildableIOSApp extends IOSApp {
|
||||
String get deviceBundlePath => _buildAppPath('iphoneos');
|
||||
|
||||
String _buildAppPath(String type) {
|
||||
return fs.path.join(getIosBuildDirectory(), type, name);
|
||||
return fs.path.join(getIosBuildDirectory(), type, _hostAppBundleName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -736,7 +736,7 @@ bool upgradePbxProjWithFlutterAssets(IosProject project) {
|
||||
final Match match = oldAssets.firstMatch(line);
|
||||
if (match != null) {
|
||||
if (printedStatuses.add(match.group(1))) {
|
||||
printStatus('Removing obsolete reference to ${match.group(1)} from ${project.hostAppBundleName}');
|
||||
printStatus('Removing obsolete reference to ${match.group(1)} from ${project.xcodeProject?.basename}');
|
||||
}
|
||||
} else {
|
||||
buffer.writeln(line);
|
||||
|
||||
@@ -622,9 +622,8 @@ 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+\]\)?: (\(.*?\))? *(.*)$');
|
||||
// * Xcode 9: 2017-09-13 15:26:57.228948-0700 localhost My App[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/
|
||||
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 ---$');
|
||||
@@ -635,9 +634,9 @@ 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);
|
||||
final String category = match.group(1);
|
||||
final String tag = match.group(2);
|
||||
final String content = match.group(3);
|
||||
|
||||
// Filter out non-Flutter originated noise from the engine.
|
||||
if (_appName != null && category != _appName) {
|
||||
|
||||
@@ -309,7 +309,7 @@ class IosProject 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');
|
||||
@@ -330,9 +330,6 @@ class IosProject 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;
|
||||
|
||||
@@ -355,19 +352,19 @@ class IosProject implements XcodeBasedProject {
|
||||
File get podManifestLock => hostAppRoot.childDirectory('Pods').childFile('Manifest.lock');
|
||||
|
||||
/// The 'Info.plist' file of the host app.
|
||||
File get hostInfoPlist => hostAppRoot.childDirectory(_hostAppBundleName).childFile('Info.plist');
|
||||
File get hostInfoPlist => 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');
|
||||
@@ -408,6 +405,26 @@ class IosProject implements XcodeBasedProject {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// The bundle name of the host app, `My App.app`.
|
||||
Future<String> get hostAppBundleName 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
|
||||
// It may be expensive, but the only source of truth for the name is
|
||||
// Xcode's interpretation of the build settings.
|
||||
String productName;
|
||||
if (xcode.xcodeProjectInterpreter.isInstalled) {
|
||||
final Map<String, String> xcodeBuildSettings = await buildSettings;
|
||||
if (xcodeBuildSettings != null) {
|
||||
productName = xcodeBuildSettings['FULL_PRODUCT_NAME'];
|
||||
}
|
||||
}
|
||||
if (productName == null) {
|
||||
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.
|
||||
@@ -415,11 +432,16 @@ class IosProject implements XcodeBasedProject {
|
||||
if (!xcode.xcodeProjectInterpreter.isInstalled) {
|
||||
return null;
|
||||
}
|
||||
_buildSettings ??= await xcode.xcodeProjectInterpreter.getBuildSettings(
|
||||
Map<String, String> buildSettings = _buildSettings;
|
||||
buildSettings ??= await xcode.xcodeProjectInterpreter.getBuildSettings(
|
||||
xcodeProject.path,
|
||||
_hostAppBundleName,
|
||||
_hostAppProjectName,
|
||||
);
|
||||
return _buildSettings;
|
||||
if (buildSettings != null && buildSettings.isNotEmpty) {
|
||||
// No timeouts, flakes, or errors.
|
||||
_buildSettings = buildSettings;
|
||||
}
|
||||
return buildSettings;
|
||||
}
|
||||
|
||||
Map<String, String> _buildSettings;
|
||||
@@ -498,7 +520,7 @@ class IosProject implements XcodeBasedProject {
|
||||
Directory get pluginRegistrantHost {
|
||||
return isModule
|
||||
? _flutterLibRoot.childDirectory('Flutter').childDirectory('FlutterPluginRegistrant')
|
||||
: hostAppRoot.childDirectory(_hostAppBundleName);
|
||||
: hostAppRoot.childDirectory(_hostAppProjectName);
|
||||
}
|
||||
|
||||
void _overwriteFromTemplate(String path, Directory target) {
|
||||
@@ -759,7 +781,7 @@ class MacOSProject implements XcodeBasedProject {
|
||||
@override
|
||||
final FlutterProject parent;
|
||||
|
||||
static const String _hostAppBundleName = 'Runner';
|
||||
static const String _hostAppProjectName = 'Runner';
|
||||
|
||||
@override
|
||||
bool existsSync() => _macOSDirectory.existsSync();
|
||||
@@ -803,13 +825,13 @@ class MacOSProject 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');
|
||||
|
||||
Reference in New Issue
Block a user