AdvancedLighting in chapter 20

Hello Caroline,
I get a new MacBook Pro (M1) to run the chapter 20 AdvancedLighting source code, but I receive this error:

Execution was interrupted, reason: EXC_BREAKPOINT (code=1, subcode=0x1a6b35d78).
The process has been left at the point where it was interrupted, use “thread return -x” to return to the state before expression evaluation.

Hi there :smiley:

If this is in the playground, it’s to do with Apple changing the way the library is created.

In Renderer.swift, change:

guard let path = Bundle.main.path(forResource: "Shaders", ofType: "metal") else { fatalError() }
let input = try String(contentsOfFile: path, encoding: String.Encoding.utf8)
let library = try device.makeLibrary(source: input, options: nil)


 let library = device.makeDefaultLibrary()!

and it should work. My M1 does :smiley:

You’ll need to change Renderer.swift for the playground pages 1. reflection, 2. refraction and 3. water.

1 Like