2017-01-11 8 views
2

소비에 엔티티를 찾을 수없는, 프레임 워크의 핵심 데이터를 사용, 내 포드 사양은있다 내가코코아 포드가 나는 cocoapod의 프레임 워크를 만든 응용 프로그램

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSFetchRequest could not locate an NSEntityDescription for entity name 'EntityName'' 

내가 시도하는 것을 아주 확실하지 않다있어 I 포드로 설치하지만 데이터 모델 파일에 모듈 이름을 변경했다 그러나 때, 프레임 워크 작업 공간에서 다른 대상의 응용 프로그램 아무런 효과가 없다. (내가 다시 프레임 워크 '현재 제품 모듈'에 프로젝트의 이름에서 갔다.

를 내가 작업 공간의 포드 프로젝트의 데이터 모델 파일을 참조 할.

내 문제는 내가 만든 방법에 의해 발생 된

답변

0

내 핵심 데이터 스택, 특히 관리 대상 객체 모델. 포드 소비자로 존재하지 않는 번들 URL에서 생성했습니다. 이제는 정의에 있습니다. 번들이 작업 영역에있는 것처럼 사용할 수 있는지 확인합니다. (데모 응용 프로그램의 경우) 또는 내 pod 파일에 정의 된 자원 번들의 이름 아래에 다음과 같이 입력하면 다음과 같이 표시됩니다.

fileprivate lazy var managedObjectModel: NSManagedObjectModel = { 

// the moc's model should be accessible via apps in this workspace 
// or through the module that cocoapods will create as part of the file's 
// resource bundle, as such, we need to look in two different places 
// to use the correct bundle at run time 
var rawBundle: Bundle? { 

    if let bundle = Bundle(identifier: "com.thefredelement.Framework") { 
     return bundle 
    } 

    guard 
     let resourceBundleURL = Bundle(for: type(of: self)).url(forResource: "FrameworkModel", withExtension: "bundle"), 
     let realBundle = Bundle(url: resourceBundleURL) else { 
      return nil 
    } 

    return realBundle 
} 

guard let bundle = rawBundle else { 
    print("Could not get bundle that contains the model ") 
    return NSManagedObjectModel() 
} 

guard 
    let modelURL = bundle.url(forResource: self.model, withExtension: "momd"), 
    let model = NSManagedObjectModel(contentsOf: modelURL) else { 
     print("Could not get bundle for managed object model") 
     return NSManagedObjectModel() 
} 

return model 
}()