Skip to content
This repository

.xcdatamodeld bundle detection #102

Merged
merged 1 commit into from over 2 years ago

1 participant

Jonathan 'Wolf' Rentzsch
Deleted user
ghost commented

I've added bundle support for .xcdatamodeld files
Approach I used is kinda naive and I did test it with Xcode 4.3.2
Please see for yourself if it makes any sense
Cheers

Jonathan 'Wolf' Rentzsch
Owner

I like it. Thanks, merged.

Jonathan 'Wolf' Rentzsch rentzsch merged commit 00e21f6 into from
Jonathan 'Wolf' Rentzsch rentzsch closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Apr 13, 2012
Alexander Zats Added support for xcdatamodeld bundle (current version will be chosen…
… automatically)
536bc0f
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 15 additions and 0 deletions. Show diff stats Hide diff stats

  1. +15 0 mogenerator.m
15 mogenerator.m
@@ -538,6 +538,21 @@ - (void)setModel:(NSString*)path;
538 538 {
539 539 assert(!model); // Currently we only can load one model.
540 540
  541 + // We will try to detect a bundle, not sure about compatabilty with the older Xcode versions
  542 + BOOL isDirectory = NO;
  543 + // it's a directory, let's try to find a ".xccurrentversion" file so we can locate current version of the model
  544 + if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDirectory] && isDirectory) {
  545 + // in 4.x version of Xcode there is a .xccurrentversion plist with _XCCurrentVersionName key pointing to the current model
  546 + NSString *xccurrentversionPath = [path stringByAppendingPathComponent:@".xccurrentversion"];
  547 + if ([[NSFileManager defaultManager] fileExistsAtPath:xccurrentversionPath]) {
  548 + NSDictionary *xccurrentversionPlist = [NSDictionary dictionaryWithContentsOfFile:xccurrentversionPath];
  549 + NSString *currentModelName = [xccurrentversionPlist valueForKey:@"_XCCurrentVersionName"];
  550 + if (currentModelName) {
  551 + path = [path stringByAppendingPathComponent:currentModelName];
  552 + }
  553 + }
  554 + }
  555 +
541 556 origModelBasePath = [path stringByDeletingLastPathComponent];
542 557
543 558 if( ![[NSFileManager defaultManager] fileExistsAtPath:path]){

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.