**TODO: Figure out why Xcode detaches from the process after you take a Metal snapshot, leavin the window there forever**
## Basics
1. Open XCode
2. Create a new Project using the External Build Tool configuration
3. Set the Build Tool for the target to either:
-`/usr/bin/true` - this is essentially a no-op if you want to be building elsewhere
-`../bin/build.sh` (or similar) - the path to your build script. IMPORTANT: it seems Xcode doesn't resolve absolute paths, just paths relative to the project location.
Debugging this way, you can have Xcode run an executable in a .app or just from any directory. There do seem to be differences in the ways some graphics systems are initialized - I get different window scaling in each case.
_I didn't have any luck with any of Xcode's graphics debugging utilities while developing for OpenGL._
### Metal
If you want to use XCode's Metal Graphics Debugging utilities, follow these steps:
1.`Product > Scheme > Edit Scheme > Diagnostics`
2. Turn on/off any options in the Metal section at the bottom.
*Note: Some of these will crash your app if you fail their checks.*
## Errors
**The specified architecture 'arm64-*-*' is not compatible with 'x86_64-apple-macosx10.13.0' in '/Users/ps/work/minos/p_scratch/package/scratch.app/Contents/MacOS/scratch'**
_This will happen if you are trying to debug an x86/x86_64 executable on an arm machine._
1. Go to Product > Destination > Destination Architectures > Show Both