updateLauncherName method
void
updateLauncherName(
)
override
Implementation
@override
void updateLauncherName() {
if (!common.fileExists(context.iosInfoPlistPath)) {
common.logSkipped(
"iOS launcher name",
context.iosInfoPlistPath,
"file does not exist",
);
return;
}
final plistFileData = common.readFile(context.iosInfoPlistPath);
final desiredBundleName = common.fetchLauncherName(context);
final parsed = XmlDocument.parse(plistFileData);
final keyElements = parsed.findAllElements("key").toList();
final hasDisplayName = keyElements
.any((element) => element.innerText == "CFBundleDisplayName");
final hasBundleName =
keyElements.any((element) => element.innerText == "CFBundleName");
if (!hasBundleName) {
throw Exception(
"Bundle name key CFBundleName not found in ${context.iosInfoPlistPath}.");
}
var updated = _replacePlistStringValue(
plistFileData,
"CFBundleName",
desiredBundleName,
);
if (hasDisplayName) {
updated = _replacePlistStringValue(
updated,
"CFBundleDisplayName",
desiredBundleName,
);
}
common.overwriteFile(context.iosInfoPlistPath, updated);
}