To fully understand and address the issue, it's important to read the entire text. If you've recently updated your macOS to version 14, Xcode 15 and are encountering the following error when using Flutter:
(Uncategorized (Xcode): Command CodeSign failed with a nonzero exit code)

Here's a breakdown of the problem:
Running on Android Emulator: When attempting to run your application in Android Studio on an Android emulator, it functions without any issues.
Running on Simulator (iOS): However, when you try to run the app on the iOS simulator, it fails to work.
Running on Xcode: Surprisingly, if you open the application in Xcode and run it there, it functions correctly on the simulator. Yet, in Android Studio, the issue persists.
Many online solutions suggest accessing "Keychain Access > Login Certificates" and deleting all Apple certificates. You may have already tried these solutions on platforms like Stack Overflow and Apple communities, but they yielded no results.
I had the same problem, I recently bought an M2. I saw that this error occurs because I am trying to run the file that is on icloud.

The way I found was to disable synchronization

But you can also solve it by creating a local folder

I had similar weird codesign errors when compiling flutter in VSC on mac. This only started to occur when I upgraded to macOS Sonoma 1.40
So, this is how I fixed it:
First Issue: My flutter project was no longer compiling and running via VSC but it was when building within Xcode. Was getting code sign errors and compilation was failing. My project files was stored within iCloud Drive and sync was on.
Solution: So I move entire project across to a local folder on my HD and that seems to fix that issue.
Second Issue: Then another runtime issue/error popped up around firebaseinitialization being called before firebase was initialised during runtime.
Solution: I found that Xcode was not picking up GoogleService-Info.plist file in Xcode running directory so I had to add it manually in Xcode and that fixed that issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With