I just downloaded 006 for XCode (I’m running XCode 3.0) and I can’t run any OF examples that have a data directory…the app doesn’t find the files. I drilled down and it seems to be creating the data path normally (…/…/…/data/) but still doesn’t work.
All non-data related apps work though. Any ideas? Should I update my version of XCode or something? Do I have some settings wrong?
curious – is this running the apps from within xcode or outside of xcode. debug and release?
one thing that happens sometimes with IDEs is that they change the default executing directory. I know this is a problem on VS, where we have to force it to run debug from within the bin directory (would normally not run it in the same place as release).
I’m looking at the moviePlayerExample right now…
It seems to do it with both (running inside and out of xcode). At least, running the standalone app just crashes it, which I assume is due to the missing asset.
I get this error message in the debug pane:
OF_ERROR: FSPathMakeRef failed -43
OF_ERROR: Error loading movie
GDB then proceeds to run, also printing this:
Attaching to program: `/Users/grimus/dev/openFrameworks_v0.06/apps/examples/moviePlayerExample/bin/openFrameworks.app/Contents/MacOS/openFrameworks
which indicates the path of the binary it’s trying to run in any case
The “data” dir is now in the “bin” directory, right?
It used to be at the app root level I think. Anyway, I copied the data folder to the root level as well but it made no difference.
Ok so if I place the data dir three levels above the Build Products directory (which in my case is /Users/grimus/dev/of_preRelease_v0.06_xcode_FAT/apps/examples/moviePlayerExample/bin)
This is of course due to the OSX data dir calculation which is …/…/…/data/
So basically running from within XCode works if I put all data in the OF apps directory. Weird…
but I still can’t run the app from Finder (well something like the polygonExample works because it has no data).
however, I’m still puzzled that, if XCode sets the current working directory to be the build directory, how is the “…/…/…/data” path setup working for anyone? If I set it to just “data”, I can run apps from within XCode.
By the way everything used to work for me a while back (I was using 0.03)…so some update on my system must have changed things…
thanks, I ran the app, and just like in all my tests it crashed.
This is no doubt due to the fact that it’s not finding the data path, and in the moveplayer example the app will carry on and try to iterate through pixels even though the pointer is NULL.
This is sort of a bug in the example I guess, there should be a check for a NULL pointer.
In my tests, the working directory is set to “/”, just like in one of the articles I posted above. I did this check by calling getCwd() early in ofToDataPath() and passing the string back to the main app to display it in the window (is there a way to run app packages in the Finder in a terminal window?).
I’m happy to try other things, but for the moment I’m stumped…and I have no solution really, because although I can get apps running in XCode by changing the data path, I still can’t run them from the Finder.
I’m running a Mac Mini core 2 duo with OSX 10.5.7 btw…
ps a worst case scenario - you can always add the files to your xcode project (drag the movie files into xcode sidebar). This copies them to the openFrameworks.app/Contents/Resources folder which is seen by the app to exist at the same level of the internal executable.
Then in testApp::setup you can do:
ofSetDataPathRoot(""); or ofSetDataPathRoot("./");
I’ve just tried the latest OS and latest xcode without problem loading data files.
but I did notice that on the preferences of each app you can say wether or not you want them to “use curent working directory” and maybe that’s selected (on my mac no apps have this selected, and if you do, you won’t load properly via ofToDataPath).
yes – I’m not sure how to access them myself from xcode or c++ code (but it might be possible).
I did have this exact same problem when I brought over an application from an older xcode into a newer one, ie, I had a project on mac 10.5.4 (xcode 3.1.2) and brought it over to the latest osx / xcode (will edit the post with the latest numbers on my imac later today).
these are very useful if you need to fix horizontal span issues or other things about the app. but, your app has to run and for some that load media (like mine) and I wound up having to throw a “return;” at the top of update and draw not to crash, so the app could run, and I could set it back to non use current working directory Once set, recompiling etc is fine and it preserves those settings.
I did not however have this problem when I unzipped a new OF version – ie, virgin xcode project.
Honestly I don’t know how that box got to be ticked if in general it isn’t. I had successfully used 0.03, then did not develop on Xcode until I installed 0.06 recently, but have updated software on the mac over that time. Anyway at least the problem is solved, I was worried I was going to have to reinstall or something.
i’m not sure if i have grasped the problem of all of this correctly.
but since i started developing on mac i always have built just executables,
no app bundles (so i don’t know too much about them, except that they hide all the needed files inside in predefined directory structure).
then on a project using Ogre3D i found this valuable snippet:
// This function will locate the path to our application on OS X,
// unlike windows you can not rely on the curent working directory
// for locating your configuration files and resources.
// NOTE: use getcwd() or get the environment variable PWD with getenv()?
static std::string macBundlePath()
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
i used it in combination with preprocessor definitions