Which macOS and Xcode versions?
Xcode managed certificates are recommended for initial setup which uses the default login keychain (see https://developer.apple.com/forums/thread/709545?answerId=719589022#719589022)
Try opening the p12 using the Keychain Access app, which will import to the default login keychain then right click on the certificate > Evaluate "Developer ID Application: Name (Team)" for Code Signing.
You can also get info on the certificate to confirm it is valid for code signing by checking the extensions for something like this:
Extension Key Usage ( 2.5.29.15 )
Critical YES
Usage Digital Signature
Extension Basic Constraints ( 2.5.29.19 )
Critical YES
Certificate Authority NO
Extension Extended Key Usage ( 2.5.29.37 )
Critical YES
Purpose #1 Code Signing ( 1.3.6.1.5.5.7.3.3 )
If it is not valid for code signing then export again using Keychain Access.
Topic:
Code Signing
SubTopic:
Certificates, Identifiers & Profiles
Tags: