Code to enable SIP via MacOS VM project from WWDC

I’m just putting in the entire code here because I had compiler issues using what was there.

Just pasting in what was in the book and ‘assuming’ how it landed was giving me
a compiler error: Type ‘(any Error)?’ has no member ‘failure’

Thought this might help someone.

    func startVirtualMachine() {
        let options = VZMacOSVirtualMachineStartOptions()
        options.startUpFromMacOSRecovery = true
        
        virtualMachine.start(options: options, completionHandler: { (error) in
            if let error {
                fatalError("Virtual machine failed to start with \(error)")
            }
        })
    }

Cheers,

Ed

I was building on MacOS 13 using Xcode 14.3.1. My # define lines were not working and I just commented out the MacOS 14 code to work around it. Not sure what is going on but it was a quick fix. I just want to hack my way thru this quickly as I’ve got too much work to do in my day job… lol

2 Likes

Helped me. Thank you!

This topic was automatically closed after 166 days. New replies are no longer allowed.