Skip to content

Instantly share code, notes, and snippets.

@siliconsocket
Last active July 18, 2024 16:28
Show Gist options
  • Select an option

  • Save siliconsocket/80eb472189e141dc6b5e5bb3f9cc074d to your computer and use it in GitHub Desktop.

Select an option

Save siliconsocket/80eb472189e141dc6b5e5bb3f9cc074d to your computer and use it in GitHub Desktop.
Script to create a RAM disk (12 GB) to mount Xcode's derivedData for faster buildings
#!/bin/bash
gigabytes=12
capacity=$(($gigabytes * 2097152))
ramdisk=$(hdid -nomount ram://$capacity)
newfs_hfs -v DerivedData $ramdisk
diskutil mount -mountPoint ~/Library/Developer/Xcode/DerivedData $ramdisk
@siliconsocket
Copy link
Author

  1. Save this script as ramdisk.sh (or name.sh, as you want) on your Mac
  2. open terminal and type command: sh ramdisk.sh to run it (inside directory that you saved it)
  3. open Xcode (Xcode must be opened AFTER you run this script)
  4. Build your app as usually (but 3x faster)

CAUTION: RAMdisk will be filled with derived data from your App's builds, so you need to destroy RAMdisk periodically if you receive a compilation error (close Xcode, then unmount RAMdisk from your desktop with right-click, then re-run this script and re-open Xcode Again).

Tested on Mac OS Big Sur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment