Exporting a standalone executable from xCode?

Hi all,

I am just getting going with xCode and oF and was wondering if it’s possible to export some kind of build in the form of a standalone executable that could run on another mac that did not have xCode or oF installed on it.

Basically what I am hopeful of is that there is some way to export your oF awesomeness from xCode into a single file (.dmg perhaps) that could then be run on another Mac for presentation.

Similar to say how Flash compiles down to a SWF file that is OS and machine independent.

Thanks in advance.

I’m very new to OF and code myself, but i think the general idea is: when you ‘build and go’ you’re doing something like the equivalent of ‘test movie’ in flash, since in both cases a ‘product’ is being generated and run. In the case of OF with xcode, the product is an application bundle (i think this ends up in your projects ‘bin’ folder, and by default it’s called openFrameworks.app).

As i understand it, the idea is that this bundle contains everything necessary to run on another (similarly specd, same OS) machine.

when you build and go, xcode creates an executable and runs it. Whenever your program is running, it’s running an executable app in your bin folder. If you look in the bin folder you’ll see something like openFramworks.app, which you can rename to whatever.

When you distribute it make sure you include the data folder if you have anything in it. This folder needs to be in the same folder as the app or it won’t be able to find it.

Indeed you guys are both right. xCode creates an executable called openFrameworks or openFrameworksDebug inside of your projects bin folder. Funny thing is I tried to ftp this file over to my girlfriends computer last night and couldn’t get it to open so assumed it was looking for some kind of dependency. Anyway just transferred it over with a USB key and it opened fine.

Thanks for your help.


Quick question relating to this;

Is there no way to have the data folder inside the app rather than along side? Having to distribute an app with the application & a folder next to it seems like such a messy idea.

Also, i don’t suppose it’s easier than i can figure to run an xcode project using oF outside of the examples folder? If i move an example folder out, just stops working. I’m guessing it’s due to linking to the actual files, but i just cant get it to work. :slight_smile:

There is a method to do this in ofUtils.

//set the root path that ofToDataPath will use to search for files relative to the app  
//the path must have a trailing slash (/) !!!!  
void	ofSetDataPathRoot( string root );  

I think its explained here…


Its probably documented elsewhere too. I have done it but can’t find my example.

Hope that helps


Sorry for posting to an old topic, but I couldn’t find an easy answer and thought I’d post what I came up with, maybe it will help someone out.

First off, you’ll want to be sure your resource files are getting included in the app bundle; the files assigned to go in the bundle are set in Xcode in the Target, Build Phases, Copy Bundle Resources section. You can verify the files are there by right-clicking the app in the Finder and choosing Show Package Contents.

To tell OF to look in this directory:

CFURLRef appUrl = CFBundleCopyBundleURL(CFBundleGetMainBundle());  
CFStringRef appPath = CFURLCopyFileSystemPath(appUrl, kCFURLPOSIXPathStyle);  
const char *appPathChars = [(NSString *) appPath UTF8String];  
string appPathStr = string(appPathChars);  // the path to the .app dir  
CFURLRef resourceUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());  
CFStringRef resourcePath = CFURLCopyFileSystemPath(resourceUrl, kCFURLPOSIXPathStyle);  
const char *resourcePathChars = [(NSString *) resourcePath UTF8String];  
string resourcePathStr = string(resourcePathChars);  // the path from the .app dir to the resources folder  
string newPath = appPathStr + "/" + resourcePathStr + "/";  // the absolute path to the resources folder  
ofSetDataPathRoot(newPath);  // tell OF to look for resources here  

That’s been working for me so far; I hope this helps out future generations.

Hi Justron,

This block of code actually helped me a lot since all the other suggestions that I found on this forum and stack overflow did not allow me to successfully access bundle resources.

However… it only works in ONE of my projects and I cannot figure out why. I know that testApp.cpp has to be renamed testApp.mm and that you must add a new “copy files to resources folder” build phase. Is there anything else that I’m missing? an #include? an #import? a build setting?

EDIT: I forgot to mention the offending lines of code:

const char *appPathChars = [(NSString *) appPath UTF8String];  


const char *resourcePathChars = [(NSString *) resourcePath UTF8String];  

and the associated errors:

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:20: error: expected primary-expression before ‘[’ token

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:20: error: ‘NSString’ was not declared in this scope

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:20: error: expected primary-expression before ‘)’ token

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:20: error: expected `]’ before ‘appPath’

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:20: error: expected ‘,’ or ‘;’ before ‘appPath’

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:27: error: expected primary-expression before ‘[’ token

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:27: error: expected primary-expression before ‘)’ token

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:27: error: expected `]’ before ‘resourcePath’

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:27: error: expected ‘,’ or ‘;’ before ‘resourcePath’

/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:20:32: Expected expression
/Users/donjasón/Code/of_0071_osx_release/apps/myApps/OIL - openCV Flow/src/testApp.mm:27:37: Expected expression

It appears that NSString is not recognized. How can I fix that? I have already included:

#include "string.h"  

Any ideas?


How is it failing? Is it compiling OK?

Without knowing the flavor of the failure, here are some starting points:

– Are the files showing up in the app itself? Right-click the app and Show Package Contents to check.
– Files are all one level deep in resources, so don’t include any directory names. For example an image that could normally be loaded like loadImage(“images/filename.png”) needs instead to be just loadImage(“filename.png”). I wound up writing a little utility method to strip off the directory name(s) if needed (i.e. if built for Mac), and calling the utility method before referring to anything that will be stored in the app Resources.
– Files need to have unique names. So “images/filename.png” and “thumbnails/filename.png” can’t both exist in the app Resources, because they’re both competing for the one filename.png spot.
– Just double-checking: that Build Phase is called “Copy Bundle Resources”.

Otherwise, how is it failing?

Hey Justron,

Thanks for the reply. The project won’t compile due to errors from not recognizing NSString. I tried including string.h but it made no difference, and besides, string.h was not included in the project where the code worked perfectly. I made an edit to my original post including the offending lines of code and error messages. If you cannot see the edit, I’ll repost the errors.


Hmmm…I feel like I saw a similar set of errors, but also maybe not all the time…and I believe I solved them by explicitly setting the project sources in Xcode to be Objective-C++.

In the Project’s Build Settings, Under Apple LLVM compiler 4.1 - Language, set “Compile Sources As” to “Objective-C++”.

Because I think the problem here isn’t that NSString isn’t being included (and actually I don’t think it’s in string.h), I think the problem is the ‘[’ character: the compiler doesn’t know what to make of it. It’s as though things are still in C++ mode even though the file is named .mm.

Explicitly setting everything to be Objective-C++ seems to have cured that for me, and I haven’t seen any side effects…yet.

Hallelujah! It worked, although I’m still not sure why my other project which has “compile sources as” set to “according to file type” has no problem with square brackets.

Thanks for the help,

This thread is a bit out of date now. I used :




Great, this ( http://nickhardeman.com/506/stand-alone-application-in-openframeworks/ ) still works!
at least for me it did!

is there something similar to this under linux ? any ideas how to ?

Sorry can’t help you. I’ve No experience with Linux and ofx. But I suppose you’ve to look for the execution commands discribed on nickhardeman.com /…

You’re not the only ones experiencing such an issue (the compiled app won’t run on a different computer that has not installed the OF)…
Happened to me between Windows 7 computers. Compiled an app in newest OF (v0.10) in Visual Studio, and the .exe file just wouldn’t run on nephew’s or mother’s computer (it complained about missing either some DLLs or dependency files…)

Funny thing though, is that I remember creating apps in an old OF (v.0.72 and v.0.73) in Code::Blocks, and there was no problem at all…
Maybe some innovations to the OF throughout the newer and newer versions added some dependencies to it? I wonder if static linking libraries (opposed to dynamic DLL) would solve such an issue…

macOS and Windows has different problem running your app in other machines.
macOS: Translocation, codesign, dylib.
Windows: dll and VC redistributable.
Try installing Visual C++ redistributable and locate dll you need for your addon or external libs.
Here is the link: https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads.

1 Like