My issue was different than the others above and I've run into it a couple times over the years. During CI automation we run fastlane and ran into this mysterious Command CodeSign failed with a nonzero exit code. Both times the fix was to manually start up Xcode start building and then there would be a CodeSign pop up asking for credentials. It only occurs when setting up a new machine.
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: