I'm getting CodeSign failed with a nonzero exit code in Xcode

Recently I have been trying to build from unity to xcode but I’m getting an error that says:
CodeSign /Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-gifvmvezvyibexfkqrxjrdldcprz/Build/Products/ReleaseForRunning-iphoneos/ProductName.app (in target: Unity-iPhone)
cd /Users/me/Desktop/Galaxian
export CODESIGN_ALLOCATE=/Volumes/SSD/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: “iPhone Developer: name.name@outlook.com (V758H4MV3R)”
Provisioning Profile: “iOS Team Provisioning Profile: com.CasaProductions.Galaxian”
(89caa867-c147-488a-94e0-21ed5b3e3bf3)

/usr/bin/codesign --force --sign 0A39E731CA77AF6FF768015D4906543C27013E39 --entitlements /Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-gifvmvezvyibexfkqrxjrdldcprz/Build/Intermediates.noindex/Unity-iPhone.build/ReleaseForRunning-iphoneos/Unity-iPhone.build/ProductName.app.xcent --timestamp=none /Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-gifvmvezvyibexfkqrxjrdldcprz/Build/Products/ReleaseForRunning-iphoneos/ProductName.app

Warning: unable to build chain to self-signed root for signer “iPhone Developer: name.name@outlook.com (V758H4MV3R)”

/Users/me/Library/Developer/Xcode/DerivedData/Unity-iPhone-gifvmvezvyibexfkqrxjrdldcprz/Build/Products/ReleaseForRunning-iphoneos/ProductName.app: errSecInternalComponent

Command CodeSign failed with a nonzero exit code

I have tried deleting keys in Keychain Access, restarting my computer, re-downloading Xcode, and re-building from unity. Any help is appreciated. Thanks.

I’m getting this exact same issue. Please let me know once you fix it what you did. XCode 14 is definitely the culprit as it didn’t happen in XCode 13. And you can’t even install 13 as it isn’t compatible with Ventura. Leave it to Apple to ruin Unity builds lol.

@troach06 perhaps this link Warning: unable to build chain to … | Apple Developer Forums might prove beneficial, as many seem to have experienced and solved a similar issue to the one described above.

Had the same issue when installed the XCode 14. Seems that the issue is related to access your Apple Developer Certificate. Solved by deleting my previous Certificate and creating a new one.