I have been trying to build iOS app from command line (on Mac Machine) using xcodebuild command.
Here's the command I am using to export the archive:
xcodebuild -project "Path/BuildOutput/XCode/Unity-iPhone.xcodeproj" -scheme "Unity-iPhone" archive -archivePath "Path/BuildOutput/XCode/Archive.xcarchive" -destination "generic/platform=iOS" -configuration Release PROVISIONING_PROFILE="xxxxxxxx-yyyyyyyy"
The profile "xxxxxxxx-yyyyyyyy" is created on my Apple Developer website as an "Ad Hoc" type profile, and it uses a certificate with type "Distribution", which in creation is displayed as "Apple Distribution"
I am getting the following error:
error: No signing certificate "iOS Development" found: No "iOS Development" signing certificate matching team ID "XXXXXXXXXX" with a private key was found. (in target 'Unity-iPhone' from project 'Unity-iPhone')
The error does not occur when I am using a provisioning profile with type "Development" and the corresponding certificate is also "iOS Development" type. It seems that despite I specify a profile with "Ad Hoc" type, xcodebuild still tries to find a corresponding "iOS Development" type certificate while the actual certificate type does not match.
The "Apple Distribution" certificate shows up correctly when I go to XCode Preference and "Manage Certificate"
I am stuck at this point and don't know what to do. Any help would be appreciated.
I experienced this same issue with Xcode 13. Xcode seems to be mixing up profiles/certs.
In the IDE, I noticed that I could fix this issue by re-selecting the provisioning profiles for each configuration (dev/QA/prod in my case). I had to select the wrong profile for each configuration, then the correct one, and I would see the error disappear. xcodebuild worked.
To fix without messing with Xcode, I added the CODE_SIGN_IDENTITY="iPhone Distribution" option to xcodebuild
In your case: