You need to download the version you want/need from the app store. Then it will appear on your Applications folder. You won't run that installer, you can close it and just proceed with the following steps.
sudo hdiutil create -o /tmp/macOS -size 10000m -volname macOS -layout SPUD -fs HFS+J
sudo hdiutil attach /tmp/macOS.dmg -noverify -mountpoint /Volumes/MacOS
sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia --volume /Volumes/macOS
sudo hdiutil detach /Volumes/Install\ macOS\ Catalina
hdiutil convert /tmp/macOS.dmg -format UDTO -o ~/Desktop/macOS.cdr
mv ~/Desktop/macOS.cdr ~/Desktop/macOS.iso
Notes:
Install\ macOS\ Catalina.appis the downloaded installer from the app store, with future macOS releases the name will change, but it most likely will always be on the Appplications folder.- The size flag when creating the volume is set to 10000m (around 10GB) modify according to the size of the installer.
- Some times,
Error erasing disk error number (22, 0)may appear when usingcreteinstallmedia, the error isn't explicit on the cause but it's either file perms(you ran some commands with sudo and others without it) or that the volume size wasn't big enough. createinstallmediahas the--nointeractionflag available so you don't need to press Y and then enter to let it delete the empty volume.- Don't forget to delete the installer and the
/tmp/macOS.dmgfiles once you're done, otherwise they'll just take up GB of space for nothing