Search code examples
xcode4resourcesbundleshader

How to add .fsh/.vsh shader files to Xcode so they are added to Copy Bundle Resources phase automatically?


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.


Solution

  • 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': Xcode change file type