Xcode 10 Beta 3 and OS X Mohave - Segmentation Fault

Hi All,

I am having a blast trying/adapting the projects from Metal by Tutorials. Really great choices of topics!

Perhaps I have been naive in wanting to try some Swift 4.2 features, but I have installed OS X Mohave and Xcode beta 3 on a drive ( Clean ). I then downloaded the Metal by Tutorials projects ( Fresh ).

I am having an issue with building - Segmentation fault: 11 - Tutorials 5 onward.

There are 9 errors listed and the summaries are terribly verbose. Have I missed something? If there is an obvious fix, please let me know.

Thanks very much and again, thank you for such interesting and fun topics,
John Lobe

Hi @johnlobe - I’m glad you’re enjoying the book :smiley: .

Yes - beta 3 has landed and introduces the segmentation fault. It’s actually an easy fix, but will take us a little time to update the book text.

On page 91 of the pdf, you add the bridging file Common.h and you’re instructed to create typedefs for various types.

In retrospect, typedefing simd types was a bad idea. So all you have to do is not do the typedef, and as you proceed through the book adding new variables, use the full type name.

For example, further down the page where you add:

typedef struct {
  float4x4 modelMatrix;
} Uniforms;

you would add instead:

typedef struct {
  matrix_float4x4 modelMatrix;
} Uniforms;

It’s only in the C++ code in Common.h that you have to do this, as simd takes care of the type alias in Swift.

You could add the typedefs as instructed in the book, but comment them out, so that you can later remember what type you are supposed to be using.

Fantastic, your advice did the trick, Caroline!

I know that using beta software can create headaches ( Especially for tutorial creators ;-), but it was hard to resist trying out the latest developments in Swift.

Thanks again for all of the work you have put into the book(s),
John Lobe

1 Like