ios iphone“自动轻量级迁移”期间出现“找不到源商店模型”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7624502/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 21:42:37  来源:igfitidea点击:

"Can't find model for source store" occurring during iphone "Automatic Lightweight Migration"?

iosiphonecore-datacore-data-migration

提问by Greg

I'm really stuck here with upgrade testing from v1 to v2 of an iPhone application. I have IPA releases that I'm testing via ad hoc distribution via iTunes to my iPhone device, one for v1 of the app and one for v2. Note that:

我真的被困在这里,从 iPhone 应用程序的 v1 到 v2 的升级测试。我有 IPA 版本,我正在通过 iTunes 临时分发到我的 iPhone 设备进行测试,一个用于应用程序的 v1,一个用于 v2。注意:

  • v1 installs runs fine on my device
  • if I delete v1 and deploy v2 (so no migration) then it works fine
  • when I deploy v2 whilst v1 is already there I get the error: "reason=Can't find model for source store"
  • v1 安装在我的设备上运行良好
  • 如果我删除 v1 并部署 v2(所以没有迁移)那么它工作正常
  • 当我部署 v2 而 v1 已经存在时,我收到错误消息:“原因=找不到源存储模型”

A snippet from the error...*

错误的片段...*

reason=**Can't find model for source store**}, {
         URL = "file://localhost/var/mobile/Applications/AAAAF424-D6ED-40FE-AB8D-66879386739D/Documents/MyApp.sqlite";
         metadata =     {
             NSPersistenceFrameworkVersion = 320;
             <cut>
  • when I use "phone disk" to look at my device I see there is Documents/MyApp.sqlite file
  • 当我使用“手机磁盘”查看我的设备时,我看到有 Documents/MyApp.sqlite 文件

Question- Any ideas how to resolve this? What debugging/analysis could I do here? Let me know if you need any more info.

问题- 任何想法如何解决这个问题?我可以在这里做哪些调试/分析?如果您需要更多信息,请告诉我。

What I have done as an overview is:

我所做的概述是:

PS fuller version of error if this helps - this time it comes from simulating the migration error on the simulator

如果有帮助,请提供更完整的错误版本 - 这次它来自在模拟器上模拟迁移错误

, reason=Can't find model for source store}, {
    URL = "file://localhost/Users/greg/Library/Application%20Support/iPhone%20Simulator/4.3.2/Applications/69FDFDCF-631D-4191-B852-CD75151B1EA9/Documents/MyApp.sqlite";
    metadata =     {
        NSPersistenceFrameworkVersion = 320;
        NSStoreModelVersionHashes =         {
            Config = <5f92f988 71e11a66 554ae924 61887562 22b8de8a c318b110 e3e4a569 81adafa2>;
        };
        NSStoreModelVersionHashesVersion = 3;
        NSStoreModelVersionIdentifiers =         (
            ""
        );
        NSStoreType = SQLite;
        NSStoreUUID = "3B9832DA-E3A1-431B-83E8-43431A7F3452";
    };
    reason = "Can't find model for source store";
}

PSS. If this helps the contents of the core data model *.mom directory/package for each version archieve are:

PSS。如果这有助于每个版本归档的核心数据模型 *.mom 目录/包的内容是:

v1

v1

-rw-r--r--   1 greg  staff  1664  5 Sep 21:06 MyApp.mom
-rw-r--r--   1 greg  staff  2656  5 Sep 21:06 MyApp.omo
-rw-r--r--   1 greg  staff   480  5 Sep 21:06 VersionInfo.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd>">
  <plist version="1.0">
    <dict>
      <key>NSManagedObjectModel_CurrentVersionName</key>
      <string>MyApp</string>
      <key>NSManagedObjectModel_VersionHashes</key>
      <dict>
        <key>MyApp</key>
        <dict>
          <key>Config</key>
          <data>
            X5L5iHHhGmZVSukkYYh1YiK43orDGLEQ4+SlaYGtr6I=
          </data>
        </dict></dict></dict>
      </plist>

v2

v2

-rw-r--r--  1 greg  staff   497  2 Oct 12:47 MyApp 1.mom
-rw-r--r--  1 greg  staff  1601  2 Oct 12:47 MyApp 2.mom
-rw-r--r--  1 greg  staff  1695  2 Oct 12:47 MyApp.mom
-rw-r--r--  1 greg  staff  2920  2 Oct 12:47 MyApp.omo
-rw-r--r--  1 greg  staff   665  2 Oct 12:47 VersionInfo.plist

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd>">
  <plist version="1.0">
    <dict>
      <key>NSManagedObjectModel_CurrentVersionName</key>
      <string>MyApp</string>
      <key>NSManagedObjectModel_VersionHashes</key>
      <dict>
        <key>MyApp</key>
        <dict>
          <key>Config</key>
          <data>
            Z/n8092QBHPfBwInZvIm1lei53T1UtZhpNzjl3JA0gs=
          </data>
        </dict>
        <key>MyApp 1</key>
        <dict/>
        <key>MyApp 2</key>
        <dict>
          <key>Config</key>
          <data>
            Fih24clI+kZszFd3X6Gm8itq8YDxudiKnjHW8ydNmps=
          </data>
        </dict></dict></dict>
      </plist>

EDIT: Another question that is not clear to me, as raised by reviewing the link jrturton provided below is:

编辑:另一个我不清楚的问题,通过查看下面提供的链接 jrturton 提出的是:

  1. How does one now in the latest XCode version do the "Set Current Version" to the appropriate model version file? i.e. the previous posts highlights two different steps being one Adding Model Version, but then separately "Set Current Version"
  2. How is one supposed to use the Core Data Model "identifier" field which one can set for each of the core data model files. It's in the inspector. The parameter exists against for example the MyApp 1.xcdatamodel, MyApp 2.xcdatamodel, and MyApp.xcdatamodel files, so what do you need to put in each one here?
  1. 现在在最新的 XCode 版本中如何将“设置当前版本”设置为适当的模型版本文件?即之前的帖子强调了两个不同的步骤,一个是添加模型版本,另一个是“设置当前版本”
  2. 应该如何使用可以为每个核心数据模型文件设置的核心数据模型“标识符”字段。它在检查员中。该参数存在于例如 MyApp 1.xcdatamodel、MyApp 2.xcdatamodel 和 MyApp.xcdatamodel 文件中,那么您需要在每个文件中输入什么?

回答by jrturton

You set the version of your data model in the Utilities inspector (right hand pane), under the Identity and Type tab when the xcdatamodeld file is selected. This has a section called "Core Data Model", and a field called "Identifier".

在选择XCDataModeld文件时,您将在Upitities Inspector(右侧窗格)中的数据模型中的数据模型版本设置为XCDataModeld文件。这有一个名为“核心数据模型”的部分和一个名为“标识符”的字段。

You add a new model version by selecting the xcdatamodeld file, the going to Editor --> Add model version.

您可以通过选择 xcdatamodeld 文件添加新模型版本,然后转到编辑器 --> 添加模型版本。

At this point it prompts you for the previous model to base it on.

此时,它会提示您以之前的模型为基础。

If youve added a new model without going through this process the lightweight migration may not work.

如果您在未经过此过程的情况下添加了新模型,则轻量级迁移可能不起作用。

回答by Grady Player

another thing that can cause this, is if you:

可能导致这种情况的另一件事是,如果您:

  1. make version 2
  2. then edit version 1 accidentally
  3. then make version 2 default
  4. realize your change isn't there
  5. make your change again on version 2
  1. 制作版本 2
  2. 然后不小心编辑了版本 1
  3. 然后将版本 2 设为默认值
  4. 意识到你的改变不在那里
  5. 在版本 2 上再次进行更改

you get the same effect, because the version 1 that you are trying to merge from isn't the version that created the store.

您会得到相同的效果,因为您尝试从中合并的版本 1 不是创建商店的版本。

回答by Travis M.

If you made changes to your model and you made sure that you generated a model object AND don't care about the migration nor are interested in making a new version, you simply need to do a Product -> Clean and that will typically fix this issue.

如果您对模型进行了更改,并且确保生成了一个模型对象并且不关心迁移也不对制作新版本感兴趣,那么您只需要做一个 Product -> Clean,这通常会解决这个问题问题。

If you are still having this error, locate your sqlite DB and delete it. When you launch the app again it will make a new one that's built from the new model.

如果您仍然遇到此错误,请找到您的 sqlite 数据库并将其删除。当您再次启动该应用程序时,它将创建一个基于新模型构建的新应用程序。

Alternatively, you can delete the app from the simulator or, if all else fails, tap on "iOS Settings" at the top of simulator and select "Reset Content and Settings..." and it will quickly wipe the simulator so you can start fresh.

或者,您可以从模拟器中删除应用程序,或者,如果所有其他方法都失败,请点击模拟器顶部的“iOS 设置”并选择“重置内容和设置...”,它会快速擦除模拟器,以便您可以开始新鲜的。

回答by Ted

Xcode 8, i had this issue without doing migration

Xcode 8,我没有做迁移就遇到了这个问题

Can't find model for source store

找不到源商店的模型

what i did is simply

我所做的只是

Simulator > Reset Content and Settings