xcode instruments screwing up paths - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Tools & Technology (/forum-10.html)
+--- Thread: xcode instruments screwing up paths (/thread-2417.html)
xcode instruments screwing up paths - Najdorf - Sep 6, 2008 07:28 PM
after a few hours i found out that why my app crashed when trying to use the xcode instruments (activity monitor, CPU sampler, leaks etc.):
apparently using the Instruments changes the working directory to my "Macintosh HD", so it doesn't find the needed resources that are in the same folder as my app ( i checked it running "system("pwd")").
for instance using fstream (c++)
I assumed it would look for myfile.txt in the same directory of the app, and it does normally but not while using instruments
Any ideas how to fix this?
xcode instruments screwing up paths - ThemsAllTook - Sep 6, 2008 07:37 PM
Never assume your working directory at application startup will be the directory containing your application bundle; in most cases, it won't be. Use NSBundle or CFBundle to retrieve the path to your application (or more appropriately, its resources directory, since you shouldn't be storing files as siblings to it).
xcode instruments screwing up paths - Najdorf - Sep 6, 2008 08:04 PM
Thx, i'll have to get my hands in cocoa a bit then.
Though i still don't think it was such a weird thing to assume
Edit: for anyone interested, i found the problem in SDLMain.m i.e. if the app is not launched from the finder (gFinderLaunch=false) setupWorkingDirectory function is not called hence the problems.
xcode instruments screwing up paths - wyrmmage - Sep 7, 2008 02:02 PM
here's some code that I believe OSC gave me a year ago or so:
xcode instruments screwing up paths - OneSadCookie - Sep 7, 2008 02:08 PM
SDLMain.m's Cocoa; you can do it much more easily:
But Najdorf already has that code or similar; the problem was it wasn't being called