Here are the steps needed to create a project in Xcode 4 on Mac OSX and compile a shader into a shared library. Launch Xcode and go to the preferences. If you want your .dylib to build into your Xcode project folder change the 'Build Location' accordingly.


  • Choose a Mac OSX Empty Project (under 'Other'):


  • Enter a project name, "simple" in this case.


  • Now you have a newly created empty project:


  • Now let's add a target. This would be a Cocoa Library. Contrary to the Xcode 3 wiki documentation it's preferable to set up the target prior to creating new files. Doing so adds newly created files automatically to the target. If you choose to do it the other way around be sure to add your files to the target yourself.


  • Enter a name for your target. This is the name your file will end up with e.g. simple.dylib


  • It's important to set the architecture according to your Arnold distribution you're compiling against. If you don't set this explicitly, you would probably get link errors.


  • Now set up the search paths for Arnold headers and libraries:


  • You're now ready to add the shader source file and name it "simple.cpp"


  • Geek out on the shader code. Notice in the inspector to the right that the target is already set.


  • Add the libai.dylib from the bin directory of your Arnold distribution you're compiling against.


  • Click on the arrow next to the yellow products folder icon. Until now a red 'simple.dylib' should show. This means your dylib has not been created. Go to Menu->Product->Build and you'll end up with a black "simple.dylib" and the according file inside your project folder:


  • Once this dynamic library is placed where Arnold can find it you should be able to use it (for example place it in the bin directory under Arnold then type "kick -nodes" in the command-line).
  • No labels