ChristianKienle / Core-Data-Editor

Core Data Editor lets you easily view, edit and analyze applications‘ data. Core Data Editor is compatible with Mac and iOS applications and supports XML, SQLite and binary stores, visualizes all relationships and is able to edit the data and generate Objective-C code for the data model.
BSD 3-Clause "New" or "Revised" License
2.13k stars 182 forks source link

Setup: Locate default Simulator/Derived data directories #17

Closed ChristianKienle closed 7 years ago

ChristianKienle commented 10 years ago

Now that Core Data Editor no longer is sandboxed it can locate the default sim/derived data directories and use those to make the initial setup easier/semi-automatic.

yepher commented 10 years ago

@ChristianKienle

[Christain, I am very sorry to hear about your situation. You've done a great job with this app so far]

This feature has gotten a lot harder with XCode 6/ iOS 8. The data directory that persistence files are stored in moves each time the simulator is launched. There is a hidden file that will let you know the UDID and name of simulator. It is located here: ~/Library/Developer/CoreSimulator/Devices/.default_created.plist but I've not been able to figure out how to track the persistence storage points across debugger runs.

To work around this problem in my project I've taken to generating the project file in the iOS code. It is something like this:

#if !(TARGET_OS_EMBEDDED)  // This will work for Mac or Simulator but excludes physical iOS devices
- (void) createCoreDataDebugProjectWithType: (NSNumber*) storeFormat storeUrl:(NSString*) storeURL modelFilePath:(NSString*) modelFilePath {
#ifdef DEBUG   
   NSDictionary* project = @{
                              @"storeFilePath": storeURL,
                              @"storeFormat" : storeFormat,
                              @"modelFilePath": modelFilePath,
                              @"v" : @(1)
                              };

    NSString* projectFile = [NSString stringWithFormat:@"/tmp/%@.cdp", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey]];

    [project writeToFile:projectFile atomically:YES];
#endif
}
#endif

The nice thing is it works well for Mac and iOS clients.

robinmacharg commented 9 years ago

For reference, a fuller discussion of @yepher's solution can be found on his github site, including a Swift version of the above code.

ChristianKienle commented 9 years ago

thanks. I will look into it.

steprescott commented 9 years ago

Any update on a fix for this as this App is a great tool when debugging Core Data issues. I liked it so much that I bought it on the App Store in support.

ChristianKienle commented 7 years ago

@yepher @steprescott fixed

https://github.com/ChristianKienle/Core-Data-Editor/pull/41

Closing this issue.