Unverified Commit 1b07c3d7 authored by hellohuanlin's avatar hellohuanlin Committed by GitHub

[tools/ios_build_ipa] fallback to CFBundleName if CFBundleDisplayName is absent (#130752)

The display name will fallback to CFBundleName if CFBundleDisplayName is absent. 

*List which issues are fixed by this PR. You must list at least one issue.*

Fixes https://github.com/flutter/flutter/issues/120553

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
parent 2dbf594f
......@@ -378,7 +378,8 @@ class BuildIOSArchiveCommand extends _BuildIOSSubCommand {
xcodeProjectSettingsMap['Version Number'] = globals.plistParser.getValueFromFile<String>(plistPath, PlistParser.kCFBundleShortVersionStringKey);
xcodeProjectSettingsMap['Build Number'] = globals.plistParser.getValueFromFile<String>(plistPath, PlistParser.kCFBundleVersionKey);
xcodeProjectSettingsMap['Display Name'] = globals.plistParser.getValueFromFile<String>(plistPath, PlistParser.kCFBundleDisplayNameKey);
xcodeProjectSettingsMap['Display Name'] = globals.plistParser.getValueFromFile<String>(plistPath, PlistParser.kCFBundleDisplayNameKey)
?? globals.plistParser.getValueFromFile<String>(plistPath, PlistParser.kCFBundleNameKey);
xcodeProjectSettingsMap['Deployment Target'] = globals.plistParser.getValueFromFile<String>(plistPath, PlistParser.kMinimumOSVersionKey);
xcodeProjectSettingsMap['Bundle Identifier'] = globals.plistParser.getValueFromFile<String>(plistPath, PlistParser.kCFBundleIdentifierKey);
......
......@@ -30,6 +30,7 @@ class PlistParser {
static const String kCFBundleExecutableKey = 'CFBundleExecutable';
static const String kCFBundleVersionKey = 'CFBundleVersion';
static const String kCFBundleDisplayNameKey = 'CFBundleDisplayName';
static const String kCFBundleNameKey = 'CFBundleName';
static const String kMinimumOSVersionKey = 'MinimumOSVersion';
static const String kNSPrincipalClassKey = 'NSPrincipalClass';
......
......@@ -954,6 +954,8 @@ void main() {
plistUtils.fileContents[plistPath] = <String,String>{
'CFBundleIdentifier': 'io.flutter.someProject',
'CFBundleDisplayName': 'Awesome Gallery',
// Will not use CFBundleName since CFBundleDisplayName is present.
'CFBundleName': 'Awesome Gallery 2',
'MinimumOSVersion': '11.0',
'CFBundleVersion': '666',
'CFBundleShortVersionString': '12.34.56',
......@@ -992,6 +994,62 @@ void main() {
PlistParser: () => plistUtils,
});
testUsingContext(
'Validate basic Xcode settings with CFBundleDisplayName fallback to CFBundleName', () async {
const String plistPath = 'build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app/Info.plist';
fakeProcessManager.addCommands(<FakeCommand>[
xattrCommand,
setUpFakeXcodeBuildHandler(onRun: () {
fileSystem.file(plistPath).createSync(recursive: true);
}),
exportArchiveCommand(exportOptionsPlist: _exportOptionsPlist),
]);
createMinimalMockProjectFiles();
plistUtils.fileContents[plistPath] = <String,String>{
'CFBundleIdentifier': 'io.flutter.someProject',
// Will use CFBundleName since CFBundleDisplayName is absent.
'CFBundleName': 'Awesome Gallery',
'MinimumOSVersion': '11.0',
'CFBundleVersion': '666',
'CFBundleShortVersionString': '12.34.56',
};
final BuildCommand command = BuildCommand(
androidSdk: FakeAndroidSdk(),
buildSystem: TestBuildSystem.all(BuildResult(success: true)),
fileSystem: MemoryFileSystem.test(),
logger: BufferLogger.test(),
osUtils: FakeOperatingSystemUtils(),
);
await createTestCommandRunner(command).run(
<String>['build', 'ipa', '--no-pub']);
expect(
testLogger.statusText,
contains(
'[✓] App Settings Validation\n'
' • Version Number: 12.34.56\n'
' • Build Number: 666\n'
' • Display Name: Awesome Gallery\n'
' • Deployment Target: 11.0\n'
' • Bundle Identifier: io.flutter.someProject\n'
)
);
expect(
testLogger.statusText,
contains('To update the settings, please refer to https://docs.flutter.dev/deployment/ios')
);
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
ProcessManager: () => fakeProcessManager,
Platform: () => macosPlatform,
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreterWithBuildSettings(),
PlistParser: () => plistUtils,
});
testUsingContext(
'Validate basic Xcode settings with default bundle identifier prefix', () async {
const String plistPath = 'build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app/Info.plist';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment