VirtualBox/Setting up a Virtual Machine/Mac OS X

Disclaimer
Mac OS X and newer versions have had a long standing clause in their software license agreements that permits the use of macOS only on computers made by Apple. If Apple has released a version above Sonoma, confirm eligibility by referring to the given agreement for the new OS version at this link.

Otherwise, performing anything in this guide could run you into legal trouble with Apple. For non-Mac users, proceed at your own risk.

Compatibility
macOS Catalina 10.15.2 and 10.15.3 (and possibly every later version) are only compatible with VirtualBox version 6.1.4 or greater.

Installation script
The following installation script:
 * ...is free and open-source
 * ...requires only VirtualBox with its Extension Pack and dependencies that can be easily installed in a single command with most open-source package managers
 * ...downloads macOS Catalina, Mojave and High Sierra directly from Apple's servers
 * ...installs macOS without modifying the original Apple binaries and without third-party bootloaders
 * ...creates a VM that is compatible with OpenCore and can be exported (with manual modifications) to KVM/QEMU for near-native performance
 * ...runs on Linux, Windows (WSL 1, Cygwin), and macOS

https://github.com/myspaghetti/macos-guest-virtualbox - Push-button installer of macOS on VirtualBox

Manual installation
The manual installation requires access to the Mac App Store through an existing installation of macOS.

Create ISO Installation Media (not working to create iso for macOS version 12+)

 * 1) Download the macOS Installer file from the App Store (OS X El Capitan and Sierra is downloadable from Apple's website).
 * 2) When download finishes, find the app, right-click and select "Show Package Contents".
 * 3) Inside the sub-folder Contents/SharedSupport you will find a InstallESD.dmg file, Right click and copy it to the desktop or your file of choice
 * 4) Open "Disk Utility"
 * 5) Choose Images > Convert
 * 6) In the window, choose the InstallESD.dmg and the disk type to be "DVD/CD-R master for export". Also choose the name for installer disk and the final destination (if it lets you). Then click "Convert".
 * 7) After the conversion completes, you will see a .cdr file in your destination folder.
 * 8) Open "Terminal"
 * 9) Enter   (for file paths, You can also just click and drag an item into the terminal to automatically type the file path, use left and right arrow keys to navigate)
 * 10) Press enter and wait for the process to complete.
 * 11) Check your output folder for the file
 * 12) The file outputted will have the extra extension of dmg once this process is completed. Simply rename the File to .iso, it will ask you if you want to keep this title just say yes. (if your file isn't like this ignore this step)

Installation in VirtualBox
There should be 2 scenarios...
 * 1) Open VirtualBox. Click "new"
 * 2) Type the name for virtual machine and Mac OS X for type. Choose your version (if you have Mojave or Catalina, choose Mac OS X (64 bit)).
 * 3) Select memory size.
 * 4) Select "Create Virtual Disk Now"
 * 5) Choose VDI for format.
 * 6) Select storage name and size. The size should be at least 32 GB.
 * 7) Go to "Settings"
 * 8) Go to "Storage" Tab
 * 9) In the SATA controller, click "Add Optical Disk".
 * 10) Insert the .iso file.
 * 11) Go to "Display" tab.
 * 12) Set video memory to maximum value.
 * 13) Quit "Settings"
 * 14) Boot by clicking "Start".
 * 15) When it boots, you will see some data being displayed.
 * 16) This part needs clarification - UEFI Interactive Shell loads, but nothing happens. If you use the command "exit" you can shift to the EFI menu, but changing the settings doesn't seem to affect the progress of the UEFI Interactive Shell, which stops at the Shell> prompt.
 * 17) After a while, you will need to choose the language for installation. Choose your own language.
 * 18) Then you will be asked where to install macOS.
 * 19) On the upper-left corner, you will see a "Utilities" button. Click it and select "Disk Utility".
 * 20) You will see a window with different storages on the left. Choose "VBOX HARDDISK Media". Note: You may have to select View/View All Devices
 * 21) Erase the Storage by clicking the "Erase" button on the top.
 * 22) You will be prompted to enter the name for the storage. Enter your desired name and continue.
 * 23) Wait for the process to complete. Then quit Disk Utility.
 * 24) You will find a new storage media, which is like a hard disk. Choose that storage for the installation of OS X to install.
 * 25) After installation completes, the virtual machine will automatically shut down. Go to "Settings".
 * 26) Go to the "Storage" section to eject the .iso file.
 * 27) Boot virtual machine again.
 * 28) Choose system language.
 * 29) Choose allow location or not.
 * 30) You will be asked to enter your Apple ID. Even if you have an Apple ID, do not enter now.
 * 31) Accept EULA of macOS.
 * 32) Restore Time Machine Backups (if you have)
 * 33) You will see the main page of OS X, open App Store.
 * 34) Enter your Apple ID and sign in...
 * 1) You will see the main page of OS X, open App Store.
 * 2) Enter your Apple ID and sign in...
 * Scenario 1: You will sign in within a short time. Congratulations! You have done it!
 * Scenario 2: It took ages. Stop signing in and check the references below.