Xcode 3.x IDE for Processing development « Changing Tides – Brenda Moon
I’ve been having a look at the Processing language (http://www.processing.org/). After using the Processing IDE for a while, I decided to try using the Xcode IDE instead of the Processing one. I’m a beginner with both Java and Processing, and I had a difficult time getting it to work. The only instructions I could find were for an older version of Xcode, and didn’t make sense with the new version. But I have it working now (at least as far as my testing can tell).
Here is what I’ve done:
- Create a new Java project in Xcode – I think I used Java Application or maybe Java Applet template.
- Copy core.jar from the processing library folder (/Applications/Processing 0135/lib/core.jar – in my case) into the lib folder in your Xcode project. I couldn’t find any way to do this inside Xcode, I did it using Finder to copy the file. The Xcode lib directory is automatically created in the directory you set for your Xcode project.
- Put the ‘data‘ sub-directory with your Processing applications resources (graphics and fonts) into the resources directory in your Xcode project. It also works if you put it in the bin directory, but anything in there gets wiped out if you do a Clean before doing a build. I also did this outside of Xcode using Finder.
- I used the instructions from Chapter 14 of “Processing – Creative Coding and Computational Art” by Ira Greenberg on how to setup a Processing project inside the Java development environment. The Processing IDE is clever enough to run the same code if you want to move back into it. In the book he talks briefly about Java mode on page 162 and says that he will refer to it in more detail in Chapter 14. But the printed book I’ve got only goes up to Chapter 13. On the publishers site the book details page (http://www.friendsofed.com/book.html?isbn=159059617x) includes links to PDF versions of “Chapter 14: 3D Rendering in Java Mode” and an extra appendix - “Appendix C: Integrating Processing within Java”. Both of which are very useful for trying to get Processing working in a Java IDE. Here is my first (very boring) test:
import processing.core.*;
public class MoonPhases extends PApplet {
// add 'private' in front of any variables declared outside the setup() function
private int frame_rate = 20;
public static void main ( String args[] ) {
// has to match your class name!
PApplet.main( new String[]{"MoonPhases"} );
}
// add 'public' in front of any functions
public void setup ()
{
size(300, 300, P3D);
frameRate(frame_rate);
}
public void draw ()
{
background(0);
stroke(51,255,51);
line(150, 50, 50, 50, 150, 50);
}
}
I’ve also set up a Subversion (SVN) repository and I’m using that from Xcode. I imported my project into SVN, deleted it and then checked it out from SVN. I’ve found the doing a Build -> Clean deletes the hidden SVN files and then you can’t commit the whole project because it thinks you don’t have those directories checked out. I’ve tried to find a fix for this but haven’t had any luck.
One suggestion I found while looking for a solution was to not have the build directory in the repository and to tell Xcode to use a directory outside the Project directory being managed by SVN. I’ve done this using Project -> Edit Project Settings. The Build Products location is set on the General tab.
But the Clean also removes the files from the jars, bin and dist directories which then can’t be committed to SVN. I’d welcome any suggestions on how to fix this.
