Xcode 6 keeps renaming my app's directory in iOS8 simulator after each run.

后端 未结 5 796
情歌与酒
情歌与酒 2020-11-29 04:05

I\'m running Xcode 6 Beta 5 but this has been happening since the first beta. My app\'s directory in the simulator keeps being renamed after each run. It took me a while to

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-29 05:03

    USE SIMPHOLDERS

    I used this app on Xcode 5 opens the Documents folder, for the currently running app in the simulator, in Finder.

    http://simpholders.com/

    not ready for Xcode 6 yet (as of sep 24 2014) but saves all this hassle.

    In Xcode 6 / iOS8 The bundle is now separate from the data./ The application GUID is regenerated between runs in Xcode (not sure why)

      DOCUMENTS DIR:/Users/gbxc/Library/Developer/CoreSimulator/Devices/AC79941F-EC56-495E-A077-773EEE882732/data/Containers/Data/Application/C220D351-0BE7-46BA-B35E-D16646C61A3F/Documents
    mainBundlePath_:/Users/gbxc/Library/Developer/CoreSimulator/Devices/AC79941F-EC56-495E-A077-773EEE882732/data/Containers/Bundle/Application/12200D1D-9B67-408B-BCF7-38206CBE0940/myappname.app/BLANK_BLOG_SCALED.jpg
    

    1. FIND THE DEVICES FOLDER in SIMULATOR

    /Users/gbxc/Library/Developer/CoreSimulator/Devices/
    

    open each /device.plist to see which GUID is which device in XCode - I think this is static

    3. FIND THE DEVICE you're running on iPad 2 - I think this is static

    /Devices/AC79941F-EC56-495E-A077-773EEE882732
    

    4. Find your application /Documents folder

    /AC79941F-EC56-495E-A077-773EEE882732/data/Containers/Data/Application/C220D351-0BE7-46BA-B35E-D16646C61A3F/Documents
    

    BEWARE the GUID C220D351-0BE7-46BA-B35E-D16646C61A3F is regenerated everytime the app is run in XCode 6

     NSArray *paths_ = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
            if(paths_){
                _docsDir = [paths_ firstObject];
                DebugLog(@"DOCUMENTS DIR:%@",_docsDir);         
            }else{
                ErrorLog(@"paths_ is nil - cant get Documents directory");
            }
    

    MAIN BUNDLE path

    NSString *mainBundlePath_ = [[NSBundle mainBundle] pathForResource:@"someimageinyourbundle" ofType:@"jpg"];
    /AC79941F-EC56-495E-A077-773EEE882732/data/Containers/Bundle/Application/12200D1D-9B67-408B-BCF7-38206CBE0940/clarksonsiq.app/BLANK_BLOG_SCALED.jpg
    

    NEVER CACHE THE PATH to /Documents between runs it will change.

    I was serializing it to a plist and couldnt figure out why they kept disappearing

    The GUID above /Documents keeps changing between runs but if you have /Documents open in Finder the folder stays open.

    https://devforums.apple.com/thread/235911?tstart=0
    
    https://devforums.apple.com/thread/238754?tstart=0
    

提交回复
热议问题