Xcode 数据模型编辑器没有出现

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8646800/
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-09-14 22:50:15  来源:igfitidea点击:

Xcode Data Model Editor not appearing

xcodeios5editordatamodel

提问by Sanjiv Jivan

I'm using Xcode 4.2 and I'm trying to use Core Data. Upon clicking the .xcdatamodeld file I see a strange view instead of the Data Model Editor View.

我正在使用 Xcode 4.2,我正在尝试使用 Core Data。单击 .xcdatamodeld 文件后,我看到一个奇怪的视图,而不是数据模型编辑器视图。

Data Model Editor

数据模型编辑器

I have reinstalled Xcode 4.2 and have even created a starter project from scratch with Core Data Enabled but the issue persists. When I create a Data Model using new file --> Data Model. It is not being recognized as a DataModel. Ctrl+Click --> 'Open As' only displays a "Preview" option. I compared my basic project with that created on a different machine (where everything works fine). A directory diff reveals :

我已经重新安装了 Xcode 4.2,甚至从头开始创建了一个启用 Core Data 的入门项目,但问题仍然存在。当我使用新文件 --> 数据模型创建数据模型时。它未被识别为 DataModel。Ctrl+单击 -->“打开为”仅显示“预览”选项。我将我的基本项目与在不同机器上创建的项目(一切正常)进行了比较。目录差异显示:

  1. The Foos.xcdatamodeld file was placed under the "Copy Bundle Resources" section of the project's Build Phase instead of being under the "Compile Sources" section. I moved this file to the "Compile Sources" section but the data model editor still doesn't display.

  2. The Foos/Foos.xcdatamodeld/.xccurrentversion file in the working project looked like

  1. Foos.xcdatamodeld 文件被放置在项目构建阶段的“复制捆绑资源”部分下,而不是在“编译源”部分下。我将此文件移至“编译源”部分,但数据模型编辑器仍未显示。

  2. 工作项目中的 Foos/Foos.xcdatamodeld/.xccurrentversion 文件看起来像


<?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>_XCCurrentVersionName</key>
   <string>Foos.xcdatamodel</string>
</dict>
</plist>

while in the non-functional one it was

而在非功能性的


<?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>
</dict>
</plist>
  1. The only other difference I noticed was that the working version had the following in the project.pbxproj file
  1. 我注意到的唯一其他区别是工作版本在 project.pbxproj 文件中有以下内容

/* Begin XCVersionGroup section */
      831B12C114A7F73600524A33 /* Foos.xcdatamodeld */ = {
         isa = XCVersionGroup;
         children = (
            831B12C214A7F73600524A33 /* Foos.xcdatamodel */,
         );
         currentVersion = 831B12C214A7F73600524A33 /* Foos.xcdatamodel */;
         path = Foos.xcdatamodeld;
         sourceTree = "";
         versionGroupType = wrapper.xcdatamodel;
      };
/* End XCVersionGroup section */

while the broken one did not have this entry.

而破损的没有这个条目。

I did a directory compare of /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates on my two machines and the templates are identical.

我在我的两台机器上做了 /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates 的目录比较,模板是相同的。

So I'm wondering what part of Xcode is causing the above differences on my primary dev machine. Any suggestions on things to try or what might be causing this issue?

所以我想知道 Xcode 的哪一部分导致了我的主要开发机器上的上述差异。关于尝试的任何建议或可能导致此问题的原因?

采纳答案by Adam Ritenauer

I ran into a similar issue. The problem was the projects directory structure and how it was configured in XCode.

我遇到了类似的问题。问题在于项目目录结构以及它在 XCode 中的配置方式。

More details here: XCode Cant' Edit CoreData Model

更多细节在这里:XCode Cant' Edit CoreData Model

回答by Sid Steward

I also ran into this.

我也遇到了这个。

I was finally able to get xcode 4.6.3 to restore the interactive editor by opening the .xcdatamodeld in my project and changing the File Type(in the file inspector) from Versioned Core Data Modelto Core Data Model. I was able to change it back to Versioned Core Data Model, later, and things kept working.

通过在我的项目中打开 .xcdatamodeld 并将文件类型(在文件检查器中)从Versioned Core Data Model更改为Core Data Model ,我终于能够让 xcode 4.6.3 恢复交互式编辑器。后来我能够将其改回Versioned Core Data Model,并且一切正常。

回答by yoshitech

I had the same problem, but by creating another user account on my Mac, I was able to create a project with Core Data where the editor opens normally. It appeared my user profile was corrupt and it couldn't be resolved by reinstalling Xcode.

我遇到了同样的问题,但是通过在我的 Mac 上创建另一个用户帐户,我能够使用 Core Data 创建一个项目,其中编辑器正常打开。看来我的用户配置文件已损坏,无法通过重新安装 Xcode 来解决。

回答by Phil Hudson

When creating a new data model, go to Editor > Add Model Version

创建新数据模型时,转到编辑器 > 添加模型版本

That fixed it for me! :)

那为我修好了!:)

回答by Bretsko

I solved the problem by opening the package contents of xcdatamodeld, dragging out the file inside with the same name and using it instead, thanks to this answer.

我通过打开 xcdatamodeld 的包内容解决了这个问题,把里面的同名文件拖出来改用它,感谢这个答案