renameIOS static method
Implementation
static Future<void> renameIOS(String filePath, String appName) async {
String data = await File(filePath).readAsString();
XmlDocument document = XmlDocument.parse(data);
var keys = document
.findElements('plist')
.first
.findElements('dict')
.first
.children;
/// Removing xml elements which are generated due to line breaks (this xml parser is creating xml element as 'XmlText' for line breaks)
keys.removeWhere((element) => element is XmlText);
for (int i = 0; i < keys.length; i++) {
/// Will be true if google is already configured
if (keys[i].innerText == 'CFBundleDisplayName') {
var value = XmlElement(XmlName('string'));
value.innerText = appName;
keys.removeAt(i + 1);
keys.insert(i + 1, value);
}
}
await saveFile(filePath, document.toXmlString(pretty: true));
printFinishMessage('ios');
}