Keep App directory the same when building for iPhone Simulator?

自闭症网瘾萝莉.ら 提交于 2019-12-02 05:43:09

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;
}

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!