views:

415

answers:

2

Hi there;

I'm building an iPhone app, and my app copies a bunch of resources to the App's Documents directory on first install. While I'm developing the app, I simply modify files in the App's Documents directory for the iPhone Simulator to make it easy to test out things without having to rebuild the app.

But when I do rebuild the app, the App's GUID, which is used in it's installation directory name, is changed, and any files I had opened are now pointing at an invalid directory.

So in short, is there anyway to force the App's GUID to be constant when installing to the iPhone simulator? This would allow me to edit files in VIM and not have them "disappear' when I do a build. I've searched StackOverflow for an answer, and haven't seen any.... The closest was this:

http://stackoverflow.com/questions/271577/how-to-keep-the-iphone-simulator-application-directory-be-the-same-when-run-it-ev

But it wasn't quite the same question!

Thanks!

+1  A: 

The way I usually handle this is by creating Copy Files or Run Script Build Phase which run after the standard build process. The compile phase will be skipped if no changes have been made to the source, so only your build phases will run. Then, make sure your editor (Photoshop / vim etc.) are editing the original files, not the files in the build directory.

Nathan de Vries
This would mean that every time I want to see my changes in the simulator, I'd have to do a build (which would be somewhat quick, since it doesn't have to compile code)... This works, as you suggest, but I was hoping to have a way where I didn't have to do something like that.... Something I could do once per project and it'd "stick". Thanks though!
Brad Parks
+2  A: 

I never did find a way to do this using the app guid, but ultimately I did find a work around. All I did was put all my references to the applications installation directory into a function, and change that function so if I'm running in the simulator, it returns a hard coded directory on my system.... That way the directory would always stay the same even if I reinstall the app, so I can edit my files without losing them when I do a build.

+(NSString *) appDocsDir
{
#if TARGET_IPHONE_SIMULATOR

     NSString* result = @"/Users/brad/ezappdir";
#else

     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, 
                   NSUserDomainMask, 
                   YES); 
     NSString* result = [paths objectAtIndex:0];
#endif

    return result;
}
Brad Parks
What a hack! (Meant as a compliment.)
Steven Fisher