When I started developing apps in Flutter on my Mac, I frequently encountered the infamous “Command CodeSign failed with a nonzero exit code” error when compiling and running an app on the iOS simulator.
Even though there are quite a few possibilities why this error may have occurred, one that wasn’t widely mentioned is actually related to iCloud Drive. Long story short, residing your files somewhere in the iCloud Drive folder will result in it generating some duplicate files in the background and hence the Command CodeSign failed with a nonzero exit code” error is encountered.
The solution is really quite straightforward, simply follow the steps below:
- Move app project files outside of the iCloud Drive (I suggest not being adventurous and also ensure it isn’t under the Dropbox sync folder either).
- Execute the command “flutter clean”
- Restart the Android Studio IDE (or restart machine if it doesn’t work)