Custom Shaders stop working on iOS after pseudo-random event

I know custom shaders are a new feature in Unity 5.0, the free version so I tried it out. I started with a surface shader, then transformed it to a vertex/fragment shader with a copy-paste from unity’s site. Deployment to iOS worked just fine ! Then I played around with a custom shader up until it stopped rendering. As in, it doesn’t show up anymore, nor does the error shader display and a Shader.Find(“Custom/FurShader”) returns NULL.

What’s even freakier is that after this failed ( on MacOS the shader displays ok btw), all other custom shaders created after this point stop compiling as well !

I did “fix” this issue by creating a brand new project, created a default custom shader and it worked again. Applying the old shader back in the new project resulted in the exact same issue, the buggy shader doesn’t show up, and deleting it and all other custom shaders and creating a new custom shader from scratch results in the new shader not being compiled.

I’m attaching the shader in question because maybe I’m doing something wrong ?
I had an issue a while back related to shaders where the new lines weren’t in the style that Unity wanted. I basically extended a custom shader and used copy-paste from safari, and the paste might include \r\n or \n depending on the site’s style.

I also tried reimporting all assets, deleting the library folder of the buggy project, clean & rebuild from Xcode, save IOS build to different folder, it didn’t fix it.

EDIT : I think I solved it ! The problem is that the shader was assigned at run-time through a script, so it wasn’t on any initial object in the scene, and I think this basically omits it from the iOS build. I’ve put it on a dummy object and I can instantiate it now !

2062615–134420–FurShader.shader (2.92 KB)

Alternativly, you can also go to Edit > ProjectSettings > Graphic and add it as an entry in the Always Included Shaders

Ok, Thanks. Though I think that when you add a new shader there should be a popup asking if you want to have this available for creation in code or not. I can’t image someone having all the necessary shaders in the scene before they’re needed.

You can also put your shaders in “Resources” folder to make sure they are in there when you build your project.