Do not use the name of a viewController subclass as your Storyboard ID.

I’ve had both ‘Storyboard […] doesn’t contain a controller with identifier ‘MyCustomController’ and the cast to MyCustomController failing randomly; in one instance a cast to NSViewController worked, but MyCustomController did not.

When I set the identifier to “CustomVC” the same code works every time.