"Warning: unable to build chain to self-signed root for signer" warning in Xcode 9.2

XcodeCertificateRootCode Signing

Xcode Problem Overview


I'm attempting to migrate an Xcode project to another computer. It gives me the warning "Warning: unable to build chain to self-signed root for signer" and when it runs it crashes immediately similarly to what is shown in this Stack Overflow:

https://stackoverflow.com/questions/48749912/app-working-on-simulator-but-not-on-iphone-dyld-abort-with-payload-dyld-dyld

My issue seems similar to what is described on the Apple Developer Forums here: https://forums.developer.apple.com/thread/86161

and similar to what is described on this Stack Overflow: https://stackoverflow.com/questions/47307416/xcode-ios-app-development-code-signing

except the suggestions of deleting certificates and re-adding them, re-adding my account and restarting didn't seem to help. I have removed my developer cert for the second time and now I don't see it coming back, and I'm at a loss of knowing how to get it back since my dev portal doesn't appear to have a place to download it like it used to.

I've also tried deleting the derived data folder several times.

e: I've determined ANY project on this computer results in the same crash and warning.

Xcode Solutions


Solution 1 - Xcode

If none of the other solutions work, try adding the intermediate signing certificates to your system keychain. I found this while trying to manually create provisioning profile/certificates as nothing else was working - from the Create a New Certificate step of the New Provisioning Profile process on Apple Developer platform:

> To use your certificates, you must have the intermediate signing certificate in your system keychain. This is automatically installed by Xcode. However, if you need to reinstall the intermediate signing certificate click the link below: > Worldwide Developer Relations Certificate Authority (Expiring 02/07/2023) > Worldwide Developer Relations Certificate Authority (Expiring 02/20/2030)

After downloading these two files and double-clicking them to automatically add to the system keychain, the automatic provisioning profile in xcode started working (I didn't need to complete the manual provisioning profile process, but that's where I found the links)

Solution 2 - Xcode

I had the same problem and fixed with below steps:

  1. Open Keychain Access
  2. Select login, and click Certificates
  3. Double click Apple Worldwide Developer Relations Certificate Authority
  4. Open trust section, and set to "Use System Defaults" from "Always Trust"
  5. Clean the build folder and run

Solution 3 - Xcode

In my case the error was only resolved after I deleted Apple Worldwide Developer Relations Certification Authority which expires in 2023 from both System and login keychains and imported the other certificate that is valid until 2030. It seems that codesign was picking the incorrect one when both were present in the keychain.

Solution 4 - Xcode

I could fix the issue by downloading a new certificate from here and installing it. Look at https://developer.apple.com/de/support/expiration/ for more detail.

Solution 5 - Xcode

I have been facing same issue for days now. Finally i solved it by just changing my root CA from Key Chain Access. View in System/ Login key chains. which certificate authority is being used as signer for your personal provisioning profile's certificate. Enter a valid CA certificate and you are good to go! Hope it helps. Ciao!

Solution 6 - Xcode

@waaheeda's answer led me in the right direction to fix this.

I have a keychain in my repo which is used for signing on my CI. After renewing my iOS enterprise distribution certificate and provisioning profile and updating the keychain accordingly, my CI signing stopped working. Code signing worked locally on my own machine.

I suddenly stumbled upon this and found this part particular interesting: > Enterprise iOS Distribution Certificates generated after September 2, 2020 require the new intermediate certificate installed on any machines that will be code signing.

I therefore found the "Apple Worldwide Developer Relations Intermediate Certificate Expiration" in my local "login" keychain in Keychain Access and added it to the keychain in my repo, and it seems to have fixed the signing for now (and hopefully until 2030):

enter image description here

Solution 7 - Xcode

This is too late to answer , but if anybody still looking for solution on this thread --

this happens if you are installing certificate for the first time or installing certificate which is created on another machine

In your Xcode project go to signing capabilities enter correct bundle identifier, disable automatic signing , select appropriate profile / import / download profile

then you will find trust repair option below profile , tap on it tap on trust enter your login credentials

this will create and install following certificates

enter image description here

Solution 8 - Xcode

1.change the certificate trust: "Always Trust" ==> "Use System Defaults"

2.change "codesign" command ==> "sudo codesign" command

3.change the "Apple Worldwide Developer Relations Certificate Authority" certificate in login and system items trust: "Always Trust" ==> "Use System Defaults"

worked for me when use codesign command in command line

Solution 9 - Xcode

none of those actually worked for me. I had to delete the derived data; link, remove all the certificates and reinstall them, clean cache and had to reinstall pod files. After messing around for few hours I found a proper solution.

Solution 10 - Xcode

On Xcode 13.1 and received this error when attempting to archive my app, despite it building fine on the simulator. I didn’t have to change anything with my certificates in the keychain, just cleaning the build folder worked for me.

  1. Open “Product” menu
  2. Select “Clean Build Folder”
  3. Build / Archive your app

I’ve seen some other answers reference which certificates they’ve had, so I’ll just add that I also have the 2030 “Apple Worldwide Developer Relations Certification Authority” cert and the old one is still in my keychain as well, which I’ll probably need to delete at some point.

Solution 11 - Xcode

In the machine where you created the certificate

  1. Open keychain
  2. Look for "Apple Worldwide Developer Relations Certificate Authority"
  3. Look at the column "Expires" and check apple.com/CertificateAuthority to see which has the same expiration

In your ci

  1. Install this certificate to your system keychain

    a. via fastlane

    import_certificate(
      certificate_path: "~/Downloads/AppleWWDRCAG3.cer"
    )
    

    b. via cli

    sudo security import ~/Downloads/AppleWWDRCAG3.cer \
    -k /Library/Keychains/System.keychain \
    -T /usr/bin/codesign \
    -T /usr/bin/security \
    -T /usr/bin/productbuild
    

Solution 12 - Xcode

In addition to the other answers, make sure that if you are sudoed to root, exit out before you try to codesign, so that you are signing as the login user. My codesign was failing when I forgot that I was running as root.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChewie The ChorkieView Question on Stackoverflow
Solution 1 - XcodePaul HristeaView Answer on Stackoverflow
Solution 2 - XcodeKeshavView Answer on Stackoverflow
Solution 3 - XcodeTimofey SoloninView Answer on Stackoverflow
Solution 4 - Xcodepersec10000View Answer on Stackoverflow
Solution 5 - XcodeEurosView Answer on Stackoverflow
Solution 6 - XcodekuhrView Answer on Stackoverflow
Solution 7 - XcodeWaaheedaView Answer on Stackoverflow
Solution 8 - XcodePrincekinView Answer on Stackoverflow
Solution 9 - XcodeWimukthi RajapakshaView Answer on Stackoverflow
Solution 10 - XcodeDwigtView Answer on Stackoverflow
Solution 11 - XcodeTedView Answer on Stackoverflow
Solution 12 - Xcodematthewv789View Answer on Stackoverflow