I did everything according to documentation.i marked both the Apple WorldWide Developer certificate as always trusted..
and the iPhone Distribution one as Always trusted
CSSMERR_TP_NOT_TRUSTED build error (and sometimes but less common, is it's Archive 'Share' or 'Submit' manifestation) is the result of mistakenly modifying Trust Settings on one of your iOS Development-related certificates. The resolution is slightly different than simply needing to install the Apple WWDR Intermediate Certificate, as suggested by pixel.
Fixing the build error can be as simple as restoring the Trust Settings to "Use System Defaults" for the certificate exhibiting the Blue Circle With White Plus Sign in the header pane of Keychain Access, but can be as rigorous as requiring you to remove all copies of your iOS Development-related certificates from all Keychains, and then restore the certificates once again. One copy of each certificate type in the default keychain - typically the login keychain - will do.
See Apple's publication for the full steps to resolving this error "How do I resolve the CodeSign error: CSSMERR_TP_NOT_TRUSTED?".
CSSMERR_TP_NOT_TRUSTED with Xcode After switching to a new MacBook (and copying everything through Firewire cable), I couldn’t compile any app on my iPhone.
Compilation was always ending up with the following message:
/.../build/Debug-iphoneos/xxxxxx.app: CSSMERR_TP_NOT_TRUSTED Command /usr/bin/codesign failed with exit code 1
I checked my provisioning profiles, certificates and everything and couldn’t find a solution.
Finally, while browsing the iOS Provisioning Portal, I read this under my Development Certificate:
*If you do not have the WWDR intermediate certificate installed, click here to download now.
I downloaded this certificate and added it to Keychain Access:
I compiled my app again and it worked!
I don’t know why this certificate disappeared during my MacBook migration…
Blockquote
You need to download the Apple WWDR intermediate certificate from the Provisioning Portal. You can find the certificate in the "Certificates" tab in the portal. After downloading, just drag the certificate to the Keychain Access application.
This should resolve your issue.
Install "Apple WWDR" cirtificate http://developer.apple.com/certificationauthority/AppleWWDRCA.cer and make sure that all the certificates Trust parameter is set to "Use System Defaults" in Keychain Access
The problem was that I didn't have installed the Apple Worldwide Developer Relations Certification Authority.
You can download it from: https://developer.apple.com/support/certificates/expiration/
The installation solved problem.