Chapter 4 error

Apple changed the way playgrounds access Metal shaders in Xcode 12. You used to have to access it via the bundle, but it seems that we can now just use makeDefaultLibrary() as we do in an app.

So change the method in Utility.swift:

public func createLibrary() -> MTLLibrary {
  device.makeDefaultLibrary()!
}

Unfortunately as of Xcode 12.2, the playground will only work on Big Sur, as playgrounds now use Metal Shading Language v2.3, which is only available on Big Sur. Xcode 11 should work though.

(Also see: Chapter 2: SceneKit editor is blank - #5 by yonibentov)

5 Likes