updateXcconfigFile static method
Implementation
static Future<void> updateXcconfigFile(
String filePath,
Map<String, String> updates,
) async {
final file = File(filePath);
if (!await file.exists()) {
throw Exception('File not found: $filePath');
}
List<String> lines = await file.readAsLines();
updates.forEach((key, value) {
bool found = false;
for (int i = 0; i < lines.length; i++) {
if (lines[i].startsWith('#include')) {
continue; // Skip #include lines
}
if (lines[i].startsWith(key)) {
lines[i] = '$key=$value';
found = true;
break;
}
}
if (!found) {
lines.add('$key=$value');
}
});
await file.writeAsString(lines.join('\n'));
}