updateDevelopmentTeam method
void
updateDevelopmentTeam(
- String projectRoot, {
- String? teamId,
})
Implementation
void updateDevelopmentTeam(String projectRoot, {String? teamId}) {
if (teamId == null) return;
final pbxprojFile = File(
'$projectRoot/ios/Runner.xcodeproj/project.pbxproj',
);
if (!pbxprojFile.existsSync()) {
throw BuildException(
'project.pbxproj not found at "${pbxprojFile.path}"',
fix: 'Ensure the iOS project directory is intact.',
);
}
try {
final contents = pbxprojFile.readAsStringSync();
final pattern = RegExp(r'DEVELOPMENT_TEAM = [^;]+;');
if (!pattern.hasMatch(contents)) {
Logger.warning('DEVELOPMENT_TEAM key not found in project.pbxproj');
return;
}
final updated = contents.replaceAll(
pattern,
'DEVELOPMENT_TEAM = $teamId;',
);
pbxprojFile.writeAsStringSync(updated);
} catch (e, s) {
throw BuildException(
'Failed to update iOS DEVELOPMENT_TEAM in project.pbxproj',
fix: 'Check file permissions for "${pbxprojFile.path}".',
originalStackTrace: s,
);
}
}