Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 223
LearnCocos2D Avatar asked Jan 07 '12 12:01

LearnCocos2D


2 Answers

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".

like image 132
LearnCocos2D Avatar answered Oct 24 '22 23:10

LearnCocos2D


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

like image 8
chunkyguy Avatar answered Oct 24 '22 22:10

chunkyguy