I'm also having this issue when compiling a target that has both iOS and visionOS as supported platforms. My iOS renderer uses CustomMaterial and my visionOS renderer uses ShaderGraphMaterial. I was hoping I could use a compiler flag per platform, but the Metal compiler doesn't seem to like that.
#if !os(visionOS)
#include <RealityKit/RealityKit.h>
#endif
Gives error Token is not a valid binary operator in a preprocessor subexpression.