Apple Docs describe how to create a Swift executable to run Linux on an Intel based Mac, but the docs don't include the import
statements required for the code to compile. I've determined I need to import both Cocoa
and Virtualization
but the following code from the final section Instantiate and Start the Virtual Machine
is still generating an error:
let virtualMachine = VZVirtualMachine(configuration: configuration)
let delegate = Delegate() // Cannot find 'Delegate' in scope
virtualMachine.delegate = delegate
How do I resolve the Delegate()
constructor?
Delegate
is a class that you create. It’s expected to conform to the VZVirtualMachineDelegate
protocol. The VM will call various methods from that protocol on the delegate.
Delegation like this is a fundamental concept in Cocoa. See the Delegates and Data Sources section in the Cocoa Fundamentals Guide.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"