Include data folder inside application
OpenFrameworks is great for developing applications quickly and the data folder is easy and convenient when you are developing. But after the application is complete and you are ready to distribute/move it around, it can become problematic. For example, if you have more than one OF application in the same folder and they both need a data folder, you have a problem. The best solution I have found is by mazbox in his of64 screensaver example. He used a command that will copy your entire data folder into your resources folder relative to your application:
cp -r bin/data "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Resources";
This needs to be added to the Run Script command found in the application target. See image below.
You can check that it have been moved successfully by right clicking on the application and choosing “Show Package Contents” and it will be in Contents / Resources / data.
Now that your data folder is being copied over, we need to tell OF where to look. So we need to set the path root by calling ofSetDataPathRoot();
in the setup function.
Edit (Thanks for pointing this out Jeff 🙂
For OF < 0.8 call ofSetDataPathRoot(“../Resources/”);
and for OF >= 0.8 call ofSetDataPathRoot("../Resources/data/");
Now you can move the application around and not worry about its relation to the data folder.
Rename your Application
This may be pretty straight-forward, but in Xcode 4 things changed. It is fairly easy to do so, just click once on the application, pause a second and then click again to bring up the text input. In the image below, the project is named “emptyExample”, which can be changed to anything you desire. Click on rename and create a snapshot.
While you are building the application in Debug mode, it will say {MyApplication}Debug. To get rid of this you need to switch it to Release mode. To do this, click on the current scheme > Edit Scheme and set Build Configuration to Release. See images below.
Setting an Icon for the Application
I created an empty xcode project that switches icons dynamically based on the build configuration. Download the xcode 4 project. You can use Icon Composer on OSX to create icons, the largest being 512×512 and the smallest being 16×16. I created some icon files using the OF logo. Download the icons here: of-icons (~3MB). Put the icon.icns and icon-debug.icns files into your data folder and do a Product > Clean to let xcode know that you have new assets. Build the project and Bam; new icons.
Post a Comment