findAllEntitlements static method
Find all entitlements files for iOS/Flutter projects
Implementation
static List<File> findAllEntitlements(String projectPath, ProjectType projectType) {
final entitlements = <File>[];
if (projectType == ProjectType.flutter) {
// Flutter has a single well-known location
final flutterEntitlements = File(
path.join(projectPath, 'ios', 'Runner', 'Runner.entitlements'),
);
if (flutterEntitlements.existsSync()) {
entitlements.add(flutterEntitlements);
}
} else if (projectType == ProjectType.ios) {
// Search for all .entitlements files
final dir = Directory(projectPath);
if (dir.existsSync()) {
final files = dir.listSync(recursive: true).whereType<File>();
for (final file in files) {
if (file.path.endsWith('.entitlements')) {
entitlements.add(file);
}
}
}
} else if (projectType == ProjectType.reactNative) {
final iosDir = Directory(path.join(projectPath, 'ios'));
if (iosDir.existsSync()) {
for (final file in iosDir.listSync(recursive: true).whereType<File>()) {
if (file.path.endsWith('.entitlements') &&
!file.path.contains('/Pods/') &&
!file.path.contains('/build/')) {
entitlements.add(file);
}
}
}
}
return entitlements;
}