Skip to content

Instantly share code, notes, and snippets.

@obviousjim
Created July 28, 2012 16:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obviousjim/3193922 to your computer and use it in GitHub Desktop.
Save obviousjim/3193922 to your computer and use it in GitHub Desktop.
// This makes relative paths work in C++ in Xcode by changing directory to the Resources folder inside the .app bundle
// this way you can include your images in the copy phase of the project and don't have to rely on a data/ folder for distribution
#ifdef TARGET_OSX
ofDisableDataPath();
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX);
CFRelease(resourcesURL);
chdir(path);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment