Whenever I add a new .fsh or .vsh OpenGL ES 2.0 shader file to my project's resources, the file is added to the Compile Sources build phase where it doesn't belong. I then have to manually remove it from that phase, and manually add it to the Copy Bundle Resources build phase.
Is there any way I can tell Xcode to add files with the extension .fsh and .vsh automatically to the Copy Bundle Resources build phase?
Or is it possible to create a Build Rule that has the same effect as adding the shaders to the Copy Bundle Resources build phase?
I would prefer a solution that works for all users of the Xcode project/workspace, rather than a setting or system change each Xcode user would have to play individually.
Following is a workaround I found. If anyone has any other solutions I'd still appreciate the answer.
What you do to get the shaders into the Copy Bundle Resources build phase automatically is simply to put all the shaders in a common folder (or folder tree). I named the folder "Shaders". Then when adding the Shaders folder select Create folder references for any added folders.
As folder references the files are automatically assumed to be Bundle Resources by Xcode. You just need to be careful not to place any unwanted files into that folder respectively clean up the folder before making a release build. Also loading the shaders requires to use the path to the shader files, ie "Shaders/Examples/Blur.fsh".
My workaround is that I go to File > New File > Others > Empty files and name them as shader.vertsh and shader.fragsh.
I guess Xcode automatically adds files with dot 3/4 extensions to compile phase.
And in case you're missing the Syntax Highlighting, change the File type to 'OpenGL Shading Language Source':
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With