This lovely error has given me trouble twice in recentmonths. All related to ARKit2.0’s  environment mapping.

validateFunctionArguments:3514: failed assertion `Fragment Function(commonprofile_frag): incorrect type of texture (MTLTextureTypeCubeArray) bound at texture binding at index 4 (expect MTLTextureTypeCube) for u_radianceTexture[0].'

Environment mapping is when the camera is capturing the images around you, and it’s great because we can use that environment map to colour our 3d models more accurately (Apple does all of this for us automatically!)

The issue I got is uncommon ( 5 retuls for that search string on Google) , and as I tried to debug it I went to where the answers all suggest writing custom shaders (Yuck).

Thankfully, there is a super easy solution…. Super super super easy, so silly you’ll feel dumb like I did when you realize it. It’s not the app that’s crashing, it’s the validation coming from metal debugger…

If you edit the scheme as shown below to DISABLE Metal API validation your app will now run as expected, with lovely shading, all done by Apple.

You’re welcome (that’s to future me, who encounters this again :))

ARKit Environment Map trouble and solution.