objc2 icon indicating copy to clipboard operation
objc2 copied to clipboard

Better Xcode Metal debugging documentation

Open madsmtm opened this issue 8 months ago • 1 comments

The metal crate has some instructions for how to debug Metal in Xcode, see https://github.com/gfx-rs/metal-rs/tree/master/guide/debugging-in-xcode.

We should consider adding a similar "how-to" guide (or just copy theirs with attribution).

See also https://github.com/gfx-rs/metal-rs/issues/152.

madsmtm avatar Apr 25 '25 06:04 madsmtm

A few things I've been fighting from the guide so far, when building inside Xcode:

  • Unless I can make the build fail immediately because cargo is not found, I haven't found how to see the live compilation logs yet until the build finishes...
  • rustup from brew is not in PATH by default. Even having it in /etc/paths.d does not seem to be inherited by Xcode, and it has to be added manually under Build Settings (with a leading : because it gets appended to the existing inherited PATH): Image
  • Almost my entire tree performs a recompile versus the terminal alacritty (and terminal editor helix) that I normally use, because objc2 triggers a recompile on MACOSX_DEPLOYMENT_TARGET changing. I made sure that this var is not set under Build Settings, but it seems to be set/inferred elsewhere...
  • In this project, the working directory on launch/debug is not respected with the default Console: Xcode. It used to work when I used Debug -> Debug executable... before though, and the current workaround is to switch the Console to Terminal.

When building from the terminal, and merely using Debug -> Debug executable..., I have no clue how to save the created "Scheme" for the next time Xcode opens, so that I keep have to reconfigure the working directory and a few other settings. ~Perhaps I can create a new empty project without custom build system (at all) for that 😅~ EDIT: In the project that I have above, in the scheme editor under Build unchecking the checkboxes of the Run column makes it no longer invoke the build step:

Image

MarijnS95 avatar Jul 18 '25 20:07 MarijnS95