Repository: flutter
Issue: Tool should output better error for locked Mac keychain and other cert errors instead of `Target debug_unpack_ios failed: Exception: Failed to codesign: errSecInternalComponent`
Labels: platform-ios,tool,t: xcode,P2,team-ios,triaged-ios

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

I tried to run a project on multiple physical iOS devices but the same `Command PhaseScriptExecution failed with a nonzero exit code` error keeps happening.

It works on the simulator but does not work on physical devices. Same results happen on a fresh blank project. The same error also pops up when building using Xcode.

## Steps to Reproduce

<!-- Please tell us exactly how to reproduce the problem you are running into. -->

1. Create new Flutter project
2. Connect iOS device
3. Run the project

## Logs

<details>
<summary>Logs</summary>

<!--
      Include the full logs of the commands you are running between the lines
      with the backticks below. If you are running any "flutter" commands,
      please include the output of running them with "--verbose"; for example,
      the output of running "flutter --verbose create foo".
-->

```
  Launching lib/main.dart on aaaa in debug mode...
lib/main.dart:1
Automatically signing iOS for device deployment using specified development team in Xcode project: WVN3D5J9Q3
Xcode build done.                                            9.3s
Failed to build iOS app
Error output from Xcode build:
↳
    2022-06-30 21:46:03.153 xcodebuild[35773:845109] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionSentinelHostApplications for extension Xcode.DebuggerFoundation.AppExtensionHosts.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-06-30 21:46:03.153 xcodebuild[35773:845109] Requested but did not find extension point with identifier Xcode.IDEKit.ExtensionPointIdentifierToBundleIdentifier for extension Xcode.DebuggerFoundation.AppExtensionToBundleIdentifierMap.watchOS of plug-in com.apple.dt.IDEWatchSupportCore
    2022-06-30 21:46:03.712 xcodebuild[35773:845111]  DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/DVTiOSFrameworks/DVTiOSFrameworks-20038/DTDeviceKitBase/DTDKRemoteDeviceData.m:373
    Details:  (null) deviceType from 00008101-0009196C3A7A001E was NULL when -platform called.
    Object:   <DTDKMobileDeviceToken: 0x13176cc30>
    Method:   -platform
    Thread:   <NSThread: 0x600003078400>{number = 3, name = (null)}
    Please file a bug at https://feedbackassistant.apple.com with this warning message and any useful information you can provide.
    ** BUILD FAILED **
Xcode's output:
↳
    Writing result bundle at path:
    	/var/folders/n6/pn8cjglx0qlbpzv_fqv3frmc0000gn/T/flutter_tools.FnYXJg/flutter_ios_build_temp_dirXKzhW9/temporary_xcresult_bundle
    rsync: link_stat "/Users/seifer/dev/projects/likecash/baryacard/build/ios/Debug-iphoneos/App.framework" failed: No such file or directory (2)
    rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/b6051351-c030-11ec-96e9-3e7866fcf3a1/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
    rsync: link_stat "/Users/seifer/dev/projects/likecash/baryacard/build/ios/Debug-iphoneos/App.framework" failed: No such file or directory (2)
    rsync error: some files could not be transferred (code 23) at /AppleInternal/Library/BuildRoots/b6051351-c030-11ec-96e9-3e7866fcf3a1/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(996) [sender=2.6.9]
    Unhandled exception:
    Exception: Command "rsync -8 -av --delete --filter - .DS_Store /Users/seifer/dev/projects/likecash/baryacard/build/ios/Debug-iphoneos/App.framework /Users/seifer/dev/projects/likecash/baryacard/build/ios/Debug-iphoneos/Runner.app/Frameworks" exited with code 23
#0      Context.runSync
../…/bin/xcode_backend.dart:105
#1      Context.embedFlutterFrameworks
../…/bin/xcode_backend.dart:190
#2      Context.run
../…/bin/xcode_backend.dart:61
#3      main
../…/bin/xcode_backend.dart:17
#4      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
    Command PhaseScriptExecution failed with a nonzero exit code
    note: Using new build system
    note: Planning
    note: Build preparation complete
    note: Building targets in dependency order
    /Users/seifer/dev/projects/likecash/baryacard/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.5.99. (in target 'Toast' from project 'Pods')
    /Users/seifer/dev/projects/likecash/baryacard/ios/Pods/Pods.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 15.5.99. (in target 'FMDB' from project 'Pods')
    Result bundle written to path:
    	/var/folders/n6/pn8cjglx0qlbpzv_fqv3frmc0000gn/T/flutter_tools.FnYXJg/flutter_ios_build_temp_dirXKzhW9/temporary_xcresult_bundle
Could not build the precompiled application for the device.

Error launching application on aaaa.
Exited
```

<!-- If possible, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-arm, locale
    en-PH)
    • Flutter version 3.0.1 at /Users/seifer/dev/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fb57da5f94 (6 weeks ago), 2022-05-19 15:50:29 -0700
    • Engine revision caaafc5604
    • Dart version 2.17.1
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    • Android SDK at /Users/seifer/Library/Android/sdk
    • Platform android-32, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.68.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (3 available)
    • aaaa (mobile)   • 00008101-0009196C3A7A001E • ios            • iOS 15.1.1 19B81
    • macOS (desktop) • macos                     • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)    • chrome                    • web-javascript • Google Chrome 103.0.5060.53

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>