Xcode 16: Errata for Metal by Tutorials 4th Edition

Creating this topic to list any changes that Xcode 16 has brought us.

1 Like

Problem: uint doesn’t compile.

Solution: Change uint to uint32_t. Or at the top of Common.h, add typedef uint32_t uint;

In the bridging header, I often use uint. This does not now compile, as the module isn’t included.

The Metal Shading Language Specification includes uint to be the same as uint32_t, so I think it this this is an oversight. If you use typedef... be prepared to remove it at a future Xcode release.

Or if anyone knows which module should be included, please let me know :slight_smile:

6 Likes

Problem: var quaternion = simd_quatf(.identity) doesn’t compile. (Chapter 23 forward)

Solution: Add this to MathLibrary.swift:

extension simd_quatf {
  static var identity: simd_quatf {
    .init(angle: 0, axis: [1, 0, 0])
  }
}

In Transform.swift, change:

var quaternion = simd_quatf(.identity)
to
var quaternion: simd_quatf = .identity

In AnimationClip.swift, change:

jointAnimation.getRotation(at: time) ?? simd_quatf(.identity)
to
jointAnimation.getRotation(at: time) ?? simd_quatf.identity

2 Likes

In XCode 26, I started getting this error which may reveal the module to incude:

`- error: declaration of 'uint' must be imported from module '_DarwinFoundation2.sys_types' before it is required

1 Like

The newer version of the book which should be out soon, has removed uint entirely. You should be able to see the 5.0 code on GitHub if you select the branch.

1 Like