---
title: VZMacOSInstaller
framework: virtualization
role: symbol
role_heading: Class
path: virtualization/vzmacosinstaller
---

# VZMacOSInstaller

An object you use to install macOS on the specified virtual machine.

## Declaration

```swift
class VZMacOSInstaller
```

## Mentioned in

Installing macOS on a Virtual Machine

## Overview

Overview Initialize a VZMacOSInstaller object with a VZVirtualMachine and a file URL that refers to a macOS restore image. The following code example shows how to use a VZMacOSInstaller: // Call VZMacOSInstaller with a URL that corresponds to a local file.  // This is the storage location for the restore image the app downloads. let localRestoreImageURL = ...

// Load the latest restore image. guard let restoreImage = try? await VZMacOSRestoreImage.latestSupported else {     // Handle the error.     abort() }

// Call VZMacOSInstaller with a URL that corresponds to a local file.  // Because restoreImage came from latestSupported, its URL property refers to a  // restore image on the network. Download the restore image to the local file system. guard let (location, _) = try? await URLSession.shared.download(from: restoreImage.url, delegate: nil)      else {         // Handle the error.         abort() }

guard ((try? FileManager.default.moveItem(at: location, to: localRestoreImageURL)) != nil) else {     // Handle the error.     abort() }

DispatchQueue.main.async {     // Becuase this restore image came from VZMacOSRestoreImage.     // latestSupported, mostFeaturefulSupportedConfiguration should not be nil.     let configurationRequirements = restoreImage.mostFeaturefulSupportedConfiguration!

// Construct a VZVirtualMachineConfiguration that satisfies the configuration requirements.     let configuration = VZVirtualMachineConfiguration()     configuration.bootLoader = VZMacOSBootLoader()     configuration.platform = VZMacPlatformConfiguration()

// The following are minimum values; you can use larger values if desired.     configuration.cpuCount = configurationRequirements.minimumSupportedCPUCount     configuration.memorySize = configurationRequirements.minimumSupportedMemorySize

// Set other configuration properties as necessary.     // ...

guard ((try? configuration.validate()) != nil) else {     // Handle the error.     abort() }

let virtualMachine = VZVirtualMachine(configuration: configuration) let installer = VZMacOSInstaller(virtualMachine: virtualMachine, restoringFromImageAt: localRestoreImageURL) installer.install(completionHandler: { (result: Result) in     if case let .failure(error) = result {         // Handle the error.         abort()     } else {         // Installation was successful.     } })

// Observe progress using installer.progress object. }

## Topics

### Creating a macOS Installer

- [init(virtualMachine:restoringFromImageAt:)](virtualization/vzmacosinstaller/init(virtualmachine:restoringfromimageat:).md)

### Getting Information About an Installation

- [progress](virtualization/vzmacosinstaller/progress.md)
- [restoreImageURL](virtualization/vzmacosinstaller/restoreimageurl.md)
- [virtualMachine](virtualization/vzmacosinstaller/virtualmachine.md)

### Installing macOS

- [install(completionHandler:)](virtualization/vzmacosinstaller/install(completionhandler:).md)
- [install()](virtualization/vzmacosinstaller/install().md)

### Initializers

- [init(virtualMachine:restoreImageURL:)](virtualization/vzmacosinstaller/init(virtualmachine:restoreimageurl:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Related Documentation

- [VZVirtualMachine](virtualization/vzvirtualmachine.md)

### Installers

- [VZMacOSRestoreImage](virtualization/vzmacosrestoreimage.md)
- [VZMacOSConfigurationRequirements](virtualization/vzmacosconfigurationrequirements.md)
