detectIosBundleId method
Detects the default iOS bundle identifier from ios/Runner.xcodeproj/project.pbxproj.
Implementation
String? detectIosBundleId() {
try {
final file = File('ios/Runner.xcodeproj/project.pbxproj');
if (!file.existsSync()) return null;
final content = file.readAsStringSync();
// Match: PRODUCT_BUNDLE_IDENTIFIER = com.example.app;
final match = RegExp(r'''PRODUCT_BUNDLE_IDENTIFIER\s*=\s*([^;]+);''').firstMatch(content);
if (match != null) {
return match.group(1)?.trim().replaceAll('"', '').replaceAll("'", "");
}
} catch (e) {
print('⚠️ Failed to detect iOS bundle identifier: $e');
}
return null;
}