Cannot create an NSPersistentStoreCoordinator with a nil model

前端 未结 27 1045
囚心锁ツ
囚心锁ツ 2021-01-30 03:33

Been having my first crack at Core Data and I\'m getting the following error when running my code on my device, but it works fine on the simulator..

*

27条回答
  •  醉梦人生
    2021-01-30 04:17

    I solve it by adding the db file to the Copy Bundle Resources.

    Go to root of your project >> select your target >> Build Phases >> Copy Bundle Resources . Make sure your xcdatamodeld file has been added here.

    enter image description here

    None of the posted solutions worked for me. So, hopefully this post helps someone out there. My app only crashes in release builds btw. Lesson learned. Always test release builds!

    BTW, I found this SO post the most helpful https://stackoverflow.com/a/6708837/951349 .

提交回复
热议问题