Failed to code sign ContentView.swift – SwiftUI

11. June 2019 Swift, Xcode 3

Unfortunately if you want to leverage/play/enjoy the new SwiftUI hot reload capabilities, then you need to update your beloved macOS Mojave to Catalina alongside with the Xcode 11 beta.

Ok, so let’s image you can’t wait to download the macOS Catalina Beta (6GB) on your existing system with macOS Mojave and Xcode 10. Getting some coffe(s) during the installation, and finally you could downloaded the latest Xcode 11 Beta (7.5GB). You start with trembling fingers a new project, and goes to the ContentView.swift. You click on the “Adjust Editor Options” to see the canvas, and after a short building process instead of seeing the nice hot reloading environment you got the following error:

Failed to code sign ContentView.swift

The info box says exactly the same thing, which is not too much. Your last straw is to click on Diagnostics button, and Voila:

invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

failedToCodeSign: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

the codesign_allocate helper tool cannot be found or used

TL;DR:

run

sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer

Obviously the /Applications/Xcode-beta.app should be the path and name where you placed the Xcode 11 Beta.


3 thoughts on “Failed to code sign ContentView.swift – SwiftUI”

  • 1
    Malauch on June 22, 2019 Reply

    Thank you for help! In my case I just needed to change the command to:
    `sudo xcode-select -s /Applications/Xcode-beta.app/Contents/Developer`
    *Contents* instead of *Content*

    • 2
      petermolnar on June 22, 2019 Reply

      Thanks for pointing out Malauch! It was indeed a typo. Fixed.

  • 3
    Legolas on June 24, 2019 Reply

    Many thanks!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.