Command CodeSign failed with a nonzero exit code

I’m running this command and it fails.

ionic cordova compile ios --no-interactive --release --device --prod – --packageType=app-store --developmentTeam=**** --provisioningProfile=***

There is a very long error message but here is how it ends. It’s not saying much but there is a problem about code signing.

CodeSign /var/root/Library/Developer/Xcode/DerivedData/MyApp-ccztmzoxngbmurbvfmxpessvdbbf/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app (in target: MyApp)
    cd /Users/xcloud/workspace/DCIOSApp_DummApp/platforms/ios
    export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate

Signing Identity:     "iPhone Distribution: ****"
Provisioning Profile: "match AppStore ***"
                      (****)

    /usr/bin/codesign --force --sign D4DC6C722544727A58C7449A285185812CAD815E --entitlements /var/root/Library/Developer/Xcode/DerivedData/MyApp-ccztmzoxngbmurbvfmxpessvdbbf/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/IntermediateBuildFilesPath/MyApp.build/Release-iphoneos/MyApp.build/MyApp.app.xcent /var/root/Library/Developer/Xcode/DerivedData/MyApp-ccztmzoxngbmurbvfmxpessvdbbf/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
/var/root/Library/Developer/Xcode/DerivedData/MyApp-ccztmzoxngbmurbvfmxpessvdbbf/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app: errSecInternalComponent
Command CodeSign failed with a nonzero exit code

** ARCHIVE FAILED **


The following build commands failed:
        CodeSign /var/root/Library/Developer/Xcode/DerivedData/MyApp-ccztmzoxngbmurbvfmxpessvdbbf/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/InstallationBuildProductsLocation/Applications/MyApp.app
(1 failure)
xcodebuild: Command failed with exit code 65
[ERROR] An error occurred while running subprocess cordova.

        cordova compile ios --release --device --packageType=app-store --developmentTeam... exited with exit code 65.

I’m actally using fastlane to build and release the app. Fastlane ionic plugin is creating that command. If I can’t solve this error, I want to try to create the .xcarchive file so I can use fastlane to build the ipa after that.

Can you help me?

Did you find a solution?

Hello dear I had the same issue and tried many way to fix that but does not work. after that i realized the issue show the solve too. For me it solved after do like below image

1- Do as i mentioned in image

2- and then try to add profile developer again

For you it can solve with
1- cd /Users/xcloud/workspace/DCIOSApp_DummApp/platforms/ios
2-export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
3- readd profiles

it is worked for me i hope it can help you too