Repository: flutter
Issue: Flutter CLI cannot code sign builds and therefore cannot install on physical development device 
Labels: platform-ios,tool,t: xcode,P3,team-ios,triaged-ios

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

flutter run --flavor qa -t lib/main_qa.dart

The "It's also possible that a previously installed app with the same Bundle 
Identifier was signed with a different certificate." makes the most sense to reproduce this. As recently the certificate had expired and was refreshed. This should be done automatically e.g. in Xcode it is automatically done but there seems to be a disconnect with flutter run as flutter cannot detect or or at least cannot detect the right one. 



### Expected results

It should run!

### Actual results

Automatically signing iOS for device deployment using specified development team in Xcode project: xxxxxxxxx
Running Xcode build...
Xcode build done.                                           178.1s
Installing and launching...
════════════════════════════════════════════════════════════════════════════════
No Provisioning Profile was found for your project's Bundle Identifier or your 
device. You can create a new Provisioning Profile for your project in Xcode for 
your team by:
  1- Open the Flutter project's Xcode target with
       open ios/Runner.xcworkspace
  2- Select the 'Runner' project in the navigator then the 'Runner' target
     in the project settings
  3- Make sure a 'Development Team' is selected under Signing & Capabilities > Team. 
     You may need to:
         - Log in with your Apple ID in Xcode first
         - Ensure you have a valid unique Bundle ID
         - Register your device with your Apple Developer Account
         - Let Xcode automatically provision a profile for your app
  4- Build or run your project again

It's also possible that a previously installed app with the same Bundle 
Identifier was signed with a different certificate.

For more information, please visit:
  https://flutter.dev/docs/get-started/install/macos#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════

### Code sample

<details><summary>Code sample</summary>

```dart
As above: 

flutter run --flavor qa -t lib/main_qa.dart

The "It's also possible that a previously installed app with the same Bundle
Identifier was signed with a different certificate." makes the most sense to reproduce this. As recently the certificate had expired and was refreshed. This should be done automatically e.g. in Xcode it is automatically done but there seems to be a disconnect with flutter run as flutter cannot detect or or at least cannot detect the right one.
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

**Failed run via CLI using Flutter**

![Screen Shot 2023-11-07 at 8 38 11 PM](https://github.com/flutter/flutter/assets/3054509/40d878ac-6edb-4c97-9a08-46087cd1174a)

**Xcode is Setup as specified in Flutter CLI output**

![Screen Shot 2023-11-07 at 8 40 09 PM](https://github.com/flutter/flutter/assets/3054509/65729401-cacc-418b-b3b1-7e7cac534a6d)
![Screen Shot 2023-11-07 at 8 40 16 PM](https://github.com/flutter/flutter/assets/3054509/2e4eb2bc-f69d-47a5-a9c9-af417a958035)

**Xcode build works properly**

![Screen Shot 2023-11-07 at 8 47 09 PM](https://github.com/flutter/flutter/assets/3054509/190c923b-88dd-4395-a08c-40141b6beac3)

</details>


### Logs

<details><summary>Logs</summary>

```console
      No Provisioning Profile was found for your project's Bundle Identifier or your 
                    device. You can create a new Provisioning Profile for your project in Xcode for 
                    your team by:
                      1- Open the Flutter project's Xcode target with
                           open ios/Runner.xcworkspace
                      2- Select the 'Runner' project in the navigator then the 'Runner' target
                         in the project settings
                      3- Make sure a 'Development Team' is selected under Signing & Capabilities > Team. 
                         You may need to:
                             - Log in with your Apple ID in Xcode first
                             - Ensure you have a valid unique Bundle ID
                             - Register your device with your Apple Developer Account
                             - Let Xcode automatically provision a profile for your app
                      4- Build or run your project again
                    
                    It's also possible that a previously installed app with the same Bundle 
                    Identifier was signed with a different certificate.
                    
                    For more information, please visit:
                      https://flutter.dev/docs/get-started/install/macos#deploy-to-ios-devices
                    
                    Or run on an iOS simulator without code signing
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[✓] Flutter (Channel stable, 3.13.9, on macOS 12.6.1 21G217 darwin-x64, locale en-NZ)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.3)
[✓] VS Code (version 1.84.0)
[✓] Connected device (4 available)
[✓] Network resources

```

</details>