Update device_doctor to look through all provisioning profile files. (#2368)

* Update device_doctor to look through all provisioning profile files.

On mac, there can be multiple provisioning profiles files. Currently,
device_doctor assumes only one, and errors if it finds multiple
files.
Update device doctor to look through all files and if any of them
contain a valid profile.

Bug:https://github.com/flutter/flutter/issues/117400

* Apply suggestions from code review

Co-authored-by: Jenn Magder <magder@google.com>

* remove commented line.

Co-authored-by: Jenn Magder <magder@google.com>
diff --git a/device_doctor/lib/src/ios_device.dart b/device_doctor/lib/src/ios_device.dart
index 0c860af..7e4091a 100644
--- a/device_doctor/lib/src/ios_device.dart
+++ b/device_doctor/lib/src/ios_device.dart
@@ -93,17 +93,31 @@
     HealthCheckResult healthCheckResult;
     try {
       final String? homeDir = Platform.environment['HOME'];
-      final String profile = await eval(
+
+      final String out = await eval(
         'ls',
         <String>['$homeDir/Library/MobileDevice/Provisioning\ Profiles'],
         processManager: processManager,
       );
-      final String provisionFileContent = await eval(
-        'security',
-        <String>['cms', '-D', '-i', '$homeDir/Library/MobileDevice/Provisioning\ Profiles/$profile'],
-        processManager: processManager,
-      );
-      if (provisionFileContent.contains(deviceId!)) {
+      // Split filenames
+      final profiles = LineSplitter.split(out).toList();
+
+      // Check all provisioning profiles in the directory to
+      // to see if any contain a valid profile
+      bool validProfileFound = false;
+      for (var file in profiles) {
+        final String provisionFileContent = await eval(
+          'security',
+          <String>['cms', '-D', '-i', '$homeDir/Library/MobileDevice/Provisioning\ Profiles/$file'],
+          processManager: processManager,
+        );
+        if (provisionFileContent.contains(deviceId!)) {
+          validProfileFound = true;
+          break;
+        }
+      }
+      // If any file contained a valid profile, then set result accordingly
+      if (validProfileFound) {
         healthCheckResult = HealthCheckResult.success(kDeviceProvisioningProfileCheckKey);
       } else {
         healthCheckResult = HealthCheckResult.failure(