Command CodeSign failed with a nonzero exit code

Please The flutter app runs good in Simulator, but BUILD FAILED for real iPhone testing.
The error is (see details in steps below):
Command CodeSign failed with a nonzero exit code

I tried to build it inside the Xcode, got the same error.
=======================
I looked my login keychain, there are two keys (certificates?):
1. Apple Development: XX *** (5YYYYYYYYY)
2. Apple Distributiob: XX *** (5ZZZZZZZZZ)

But when building for real iPhone, both keys show up in the log when I use -v option. I am not sure if the Xcode messed up with two keys.
Important: how to fix the Codesign error?
=====================
I use "Automatically manage signing" in Xcode.
Here are a little more details from the command line:

/Users/jrao/Workspace/Flutter/linkbasket/build/ios/Debug-iphoneos/Runner.app/Frameworks/App.framework: errSecInternalComponent

Command CodeSign failed with a nonzero exit code

/Users/jrao/Workspace/Flutter/linkbasket/build/ios/Debug-iphoneos/Runner.app/Frameworks/Flutter.framework: errSecInternalComponent

Command CodeSign failed with a nonzero exit code

note: Using new build system

note: Planning build

note: Constructing build description


PLATFORM AND VERSION
iOS (iPhone 6 and 10, iPad air 2)
MacBook Air
macOS Catalina 10.15.1
Xcode 11.2.1 (11B500)
Please help! Thanks in advanced.

Replies

Are you using any 3rd party app builders, tools, SDKS?


Do you have a valid, paid, Developer Program account or are you using Xcode's free provisioning?


Have you been able to successfully to any device in the past?


iOS (iPhone 6 and 10, iPad air 2)


Are all three devices registered in the Member Center, and shown ok for use with Xcode in Devices and Simulators?

I am facing the same issue, how was it resolved?