I am getting this error:
CodeSign error: Certificate identity \'iPhone Developer: XXX\' appears more than once in the keychain. The codesign too
I spent for this a half-day and finally found the solution
Then close Keychain.app and go to Xcode -> Organizer
Build again your app:)