Using your shader in Xcode

MetalForge gives you two pieces of code: a .metal file with the stitchable shader, and a SwiftUI snippet that calls it. The video below walks through dropping both into a fresh Xcode project — from creating the new Metal file all the way to seeing the shader run in the preview.

  1. 1
    Create a new Metal file
    In Xcode, File → New → File → Metal File.
  2. 2
    Paste the .metal code
    Copy the Metal code from the Code tab in MetalForge and paste it into the new file.
  3. 3
    Paste the SwiftUI snippet
    Copy the Swift snippet and drop it into a new Swift file (or replace ContentView). The #Preview is included.

Tip: the SwiftUI snippet ends with a #Preview block, so once both files are in your target you can open the canvas and the shader renders without any extra wiring.