2014-05-18 4 views
0

CoreData로 RestKit을 구성하려고합니다. "원본 저장소의 모델을 찾을 수 없습니다"라는 오류 메시지가 나타납니다. 나는 Restkit RKTwitterCoreData 예제에서 설정을 사용하고 있었다. 나는 사람들이 데이터베이스를 지우라고 말하는 스택 오버플로 (stack overflow)에 비슷한 게시물을 발견했지만 어떻게해야할지 모르겠다. 시뮬레이터가 아닌 내 휴대폰에서 실행 중이다. 나는 또한 제품 : 깨끗하지만 동일한 오류를 시도했다.Restkit 0.20 CoreData 오류 "원본 저장소의 모델을 찾을 수 없습니다"

2014-05-18 12:29:16.489 What my life could be[7006:60b] I restkit:RKLog.m:34 RestKit logging initialized... 
2014-05-18 12:29:17.259 What my life could be[7006:60b] *** Assertion failure in -[AppDelegate application:didFinishLaunchingWithOptions:], /Users/Pro/Desktop/ios app/What my life could be/What my life could be/AppDelegate.m:161 
2014-05-18 12:29:17.262 What my life could be[7006:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to add persistent store with error: Error Domain=NSCocoaErrorDomain Code=134130 "The operation couldn’t be completed. (Cocoa error 134130.)" UserInfo=0x15d7fc40 {URL=file:///var/mobile/Applications/2E1DA997-E54E-4CE3-AC62-6552445D77CF/Documents/JustD.sqlite, metadata={ 
NSPersistenceFrameworkVersion = 479; 
NSStoreModelVersionHashes =  { 
    ActivityEntity = <fdd7d538 648131cf 2fe3b684 bd55169e 85a7cee4 cbec3080 94202e4c 26b97889>; 
    PriorityEntity = <74cd93d0 00ade70c ef4d0ea3 f177762d 7d342720 7aba6945 d83ee02d 96a2135c>; 
    UserDataEntity = <2ffd8aec e7c1dacc 23e14fdd 400b60c0 5a1cd9a8 07fe6138 4d0e5a30 8e0c6e28>; 
}; 
NSStoreModelVersionHashesVersion = 3; 
NSStoreModelVersionIdentifiers =  (
    "" 
); 
NSStoreType = SQLite; 
NSStoreUUID = "B1BC3FFF-F727-49E4-A44F-5C5216C58226"; 
"_NSAutoVacuumLevel" = 2;}, reason=Can't find model for source store}' 
*** First throw call stack:(0x2ec07e83 0x38f646c7 0x2ec07d55 0x2f5b00af 0xf37bb 0x313fcaad 0x313fc4f3 0x313f6b41 0x31391a07 0x31390cfd 0x313f6321 0x3387676d 0x33876357 0x2ebd2777 0x2ebd2713 0x2ebd0edf 0x2eb3b471 0x2eb3b253 0x313f55c3 0x313f0845 0xf3bc5 0x3945dab7) 
libc++abi.dylib: terminating with uncaught exception of type NSException(lldb) 

상점을 구성하는 코드 부분. CoreData 템플릿 기본 코드를 삭제했습니다. 두 가지 방법으로 오류가 발생했습니다. 참고 : "수입업자 importObjectsFromItemAtPath : ...."가 어떻게 작동하는지 모르겠습니다.

#ifdef RESTKIT_GENERATE_SEED_DB 
RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelInfo); 
RKLogConfigureByName("RestKit/CoreData", RKLogLevelTrace); 

NSError *error = nil; 
BOOL success = RKEnsureDirectoryExistsAtPath(RKApplicationDataDirectory(), &error); 
if (! success) { 
    RKLogError(@"Failed to create Application Data Directory at path '%@': %@", RKApplicationDataDirectory(), error); 
} 
NSString *seedStorePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"JustDid.sqlite"]; 
RKManagedObjectImporter *importer = [[RKManagedObjectImporter alloc] initWithManagedObjectModel:managedObjectModel storePath:seedStorePath]; 
[importer importObjectsFromItemAtPath:[[NSBundle mainBundle] pathForResource:@"activities" ofType:@"json"] 
          withMapping:activityMapping 
           keyPath:@"activity" 
           error:&error]; 
[importer importObjectsFromItemAtPath:[[NSBundle mainBundle] pathForResource:@"users" ofType:@"json"] 
          withMapping:userMapping 
           keyPath:@"user" 
           error:&error]; 
BOOL success = [importer finishImporting:&error]; 
if (success) { 
    [importer logSeedingInfo]; 
} else { 
    RKLogError(@"Failed to finish import and save seed database due to error: %@", error); 
} 

// Clear out the root view controller 
[self.window setRootViewController:[UIViewController new]]; 
#else 
/** 
Complete Core Data stack initialization 
*/ 
[managedObjectStore createPersistentStoreCoordinator]; 
NSString *storePath = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"JustD.sqlite"]; 
NSString *seedPath = [[NSBundle mainBundle] pathForResource:@"RKSeedDatabase" ofType:@"sqlite"]; 
NSError *error; 
NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:storePath fromSeedDatabaseAtPath:seedPath withConfiguration:nil options:nil error:&error]; 
NSAssert(persistentStore, @"Failed to add persistent store with error: %@", error); 

// Create the managed object contexts 
[managedObjectStore createManagedObjectContexts]; 

// Configure a managed object cache to ensure we do not create duplicate objects 
managedObjectStore.managedObjectCache = [[RKInMemoryManagedObjectCache alloc] initWithManagedObjectContext:managedObjectStore.persistentStoreManagedObjectContext]; 
#endif 
+0

도움을 받으십시오. http://stackoverflow.com/a/7626401/2050181 –

답변

1

핵심 데이터 모델의 버전을 변경했거나 핵심 데이터에 자동으로 마이그레이션을 시도하지 않았거나 명시 적으로 마이그레이션을 제공 한 것으로 보입니다. 따라서 코어 데이터가로드 될 때 버전 불일치를 감지하고 중단됩니다.

처음에는 기기에서 앱을 삭제하고 다시 설치하면 모든 것이 다시 작동합니다. 데이터 모델을 변경할 때마다이 작업을 수행해야합니다.

분명히 App Store에 가셔서 자동 마이그레이션을 연구하고 제약 조건과 (필요한 경우) 명시 적 마이그레이션을 연구해야하는 것은 바람직하지 않습니다.

0

단지 주소에 있어야 SQLite는 파일을 제거, 데이터베이스를 삭제하려면 당신이

을 기록 고려 을 /var/mobile/Applications/2E1DA997-E54E-4CE3-AC62-6552445D77CF/Documents/JustD.sqlite 콘솔에서 : 복사 번들 리소스 : RM은 /var/mobile/Applications/2E1DA997-E54E-4CE3-AC62-6552445D77CF/Documents/JustD.sqlite

0

당신은 당신의 씨앗 데이터베이스가 구축 단계에 추가하고 있는가?

저는 몇 시간 동안 똑같은 문제를 겪었고 결국에는 그렇게 간단했습니다. 시뮬레이터 배포 된 응용 프로그램 패키지를보고 있지만 시드 sqlit 파일 이었지만 어떤 이유로 managedObjectStore에서 찾을 수는 없지만 "소스 저장소에 대한 모델을 찾을 수 없습니다."오류 대신 " 더 도움이되었을 "씨앗 데이터 파일을 찾을 수 없습니다!"

관련 문제