After each launch, Xcode 6 renames the directory of my application in the iOS8 simulator.

I am running Xcode 6 Beta 5, but this is happening with the first beta. My application catalog in the simulator continues to be renamed after each launch. It took me a while to figure this out. I use this to get the dor dir link.

NSString *folder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; NSLog(@"Documents Dir: %@",folder); 

Now, for example, at the first start it will be:

/ Users / Joey / Library / Developer / CoreSimulator / Devices / 5B9930EE-A9B4-4B36-Bubb-AA864ACAF2DE / data / Containers / Data / Application / 4B10C2E4-A5C3-4C64-93B1-4069FCCB9C46 / Documents

The second launch now is:

/ Users / Joey / Library / Developer / CoreSimulator / Devices / 5B9930EE-A9B4-4B36-Bubb-AA864ACAF2DE / data / Containers / Data / Application / 7E9EB62D-115A-4092-AD23-CB6BA3E5E10F / Documents

Third launch:

/ Users / Joey / Library / Developer / CoreSimulator / Devices / 5B9930EE-A9B4-4B36-Bubb-AA864ACAF2DE / data / Containers / Data / Application / EC8F41E8-52ED-4B10-9808-B3ACC46FC6AA / Documents

This harms how with my application, because it stores links to paths for certain files in the application. This does not mean that my NSLog statement returns incorrect results, I confirmed that this happens in the Finder. He changes the name every time. Has anyone seen this? Is this a โ€œfeatureโ€ that I misunderstand?

+66
ios objective-c xcode ios8 xcode6
Aug 10 '14 at 9:55
source share
5 answers

It turns out that Xcode 6 really changes the application UUID every time, and I am mistaken for storing absolute paths.

+48
Aug 11 '14 at 2:33
source share

USE SIMPHOLDERS

I used this application on Xcode 5 by opening the Documents folder for the current application in the simulator in Finder.

http://simpholders.com/

not ready for Xcode 6 yet (starting with sep 24 2014), but it retains all these problems.

In Xcode 6 / iOS8, the package is now separated from the data. / 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 DEVICE FOLDER IN THE SIMULATOR

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

open each /device.plist file to find out what GUID this device is in Xcode - I think it's static

3. FIND THE DEVICE you are running on iPad 2 - I think it's static

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

4. Find the "Application / Documents" folder

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

CAUTION GUID C220D351-0BE7-46BA-B35E-D16646C61A3F is restored every time the application starts 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"); } 

The 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 TELL THE WAY TO / Documents between launches will change.

I serialized it to plist and couldn't understand why they kept fading

The specified GUID / Documents are constantly changing between runs, but if you have / Documents open in the Finder, the folder remains open.

 https://devforums.apple.com/thread/235911?tstart=0 https://devforums.apple.com/thread/238754?tstart=0 
+8
Sep 24 '14 at 10:12
source share

Free solution

Use the open source library OpenSim . OpenSim is an alternative to Open Source for SimPholders, written in Swift.

Paid solution

Use the SimPholder app to find out the current location of the app.

enter image description here

For xcode 6.0>

Download SimPholder 2.0 alpha 2




For xcode 5.1 <

Download SimPholders 1.5

+7
Oct 20 '14 at 15:14
source share

I can confirm that it is related to Xcode 6 not iOS 8.

I have two machines for development. On one of them I have Xcode 5. I worked all the time on this machine, and my URL was right (photo application, photos are visible).

Yesterday I checked in git form my source on a machine with Xcode 6. I noticed that my photos are no longer visible, only photos created during this application session.

After a little debugging, I realized that the file: /// var / mobile / Applications / B6A6BAEF-C90C-4A2A-93DB-E6700B88971F / Documents / changes every time the application starts.

All this time I have been working with an iOS 7 device.

Once again I want to check on a machine with Xcode 5 to confirm when I receive it.

+1
Nov 23 '14 at 13:26
source share

You only need to save the path inside the DocumentDirectory (directory / file name) and add it to the DocumentDirectory every time you upload a file ...

 -(void)saveImage:(UIImage *)image{ NSData *pngData = UIImagePNGRepresentation(image); NSString *pathInDocumentDirectory = [APP_DocumentDirectory stringByAppendingPathComponent:PROFILE_IMAGE_NAME]; NSString *filePath = [self documentsPathForFileName:pathInDocumentDirectory]; //Save pic file path - DirName/Filename.png [XYZPreferencesHelper setUserImageFilePath:pathInDocumentDirectory]; //Write the file [[NSFileManager defaultManager] createFileAtPath:filePath contents:pngData attributes:nil]; } -(void)loadSavedUserPicture{ //Load saved DirName/Filename.png NSString *pathInDocumentDirectory = [XYZPreferencesHelper getUserImageFilePath]; if (pathInDocumentDirectory != nil){ //Full path with new app Document Directory NSString *filePath = [self documentsPathForFileName:pathInDocumentDirectory]; if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]){ NSData *pngData = [NSData dataWithContentsOfFile:filePath]; UIImage *image = [UIImage imageWithData:pngData]; if (image != nil){ userPicImageView.image = image; } } } } - (NSString *)documentsPathForFileName:(NSString *)name { NSString *documentsPath = [self createRestcallDirectoryIfNotExist]; return [documentsPath stringByAppendingPathComponent:name]; } -(NSString *)createRestcallDirectoryIfNotExist{ NSString *path; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsPath = [paths objectAtIndex:0]; path = [documentsPath stringByAppendingPathComponent:APP_DocumentDirectory]; NSError *error; if (![[NSFileManager defaultManager] fileExistsAtPath:path]) //Does directory already exist? { if (![[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:&error]) { NSLog(@"Create directory error: %@", error); } } return documentsPath; } 
+1
Nov 29 '16 at 9:20
source share



All Articles