2017-01-11 4 views
2

を消費してエンティティを見つけることができない、フレームワークは、コアデータを使用して、私のポッド仕様がありますココアポッドは、私がcocoapodだフレームワークを作成したアプリ

s.resource_bundles = { 
    'FrameworkModel' => ['Model/**/*.xcdatamodeld'] 
    } 

を、すべてがデモで正常に動作しますフレームワークのワークスペース内の異なるターゲットのアプリ、私は

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

を得たポッドとして、それをインストールすると、しかし、私が試して何をかなりよく分からないが、私は、データモデルファイルにモジュール名を変更しました何の効果もありません。 (私は「現在の製品モジュール」と背面にフレームワークプロジェクトの名前から行ってきました。

を私はワークスペースのポッドプロジェクトにおけるデータモデルファイルを参照ください。

答えて

0

私の問題は、私が作成したかによって引き起こされましたポッドコンシューマとして存在しないバンドルのURLから作成していた私のコアデータスタック、特に管理オブジェクトモデルです。今は定義されています。バンドルがワークスペースにあるように利用可能かどうかを確認します(デモアプリケーションの場合)、またはこれがMy 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 
}() 
関連する問題