Application failed codesign verification. The signature was invalid, or it was not signed with an Apple submission certificate.
There could be mutliple reason why this error occurs on compile, so look for all the following and see which ones applies to your context.
Duplicate certificate registration in my keychains.
Remove one of them fixed the problem.
1. Open KeyChain Access application.
2. Select the 'login' keychain, and select in the left bottom pane 'Certificates'
3. Switch to the 'system' keychain and see if there are certificates registered in both chains.
4. Remove one of them.
5. Rebuild the application.
Your are using a BETA version of Xcode that does not support application submissions.
Your Archive target is not pointing to Distribution profile.
1. Go to Edit Schema.
2. Open the Archive Profile.
3. Set Archive configuration to Distribution.
Your are not signing the app with the correct profile, check your profiles as defined as part of your project configuration.