xcode 无法确定 CoreData 代码生成的生成文件路径

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

Could not determine generated file paths for CoreData code generation

iosxcodecore-data

提问by Sakshi

While building my project for different target I am getting this error:

在为不同的目标构建我的项目时,我收到此错误:

Could not determine generated file paths for Core Data code generation: Error Domain=NSCocoaErrorDomain Code=260 "No current version for model at path /Users/abc/Documents/Code/xyz-ios/ABC/iPhoneXMPP/SRT/Model.xcdatamodeld:" UserInfo={NSFilePath=/Users/abc/Documents/Code/xyz-ios/ABC/iPhoneXMPP/SRT/Model.xcdatamodeld, NSLocalizedDescription=No current version for model at path /Users/abc/Documents/Code/xyz-ios/ABC/iPhoneXMPP/SRT/Model.xcdatamodeld:}

无法确定核心数据代码生成的生成文件路径:错误域=NSCocoaErrorDomain 代码=260“路径/Users/abc/Documents/Code/xyz-ios/ABC/iPhoneXMPP/SRT/Model.xcdatamodeld 处的模型没有当前版本: " UserInfo={NSFilePath=/Users/abc/Documents/Code/xyz-ios/ABC/iPhoneXMPP/SRT/Model.xcdatamodeld, NSLocalizedDescription=路径 /Users/abc/Documents/Code/xyz-ios 中没有模型的当前版本/ABC/iPhoneXMPP/SRT/Model.xcdatamodeld:}

Path mentioned in error is "

错误提到的路径是“

/Users/abc/Documents/Code/xyz-ios/ABC/iPhoneXMPP/SRT/Model.xcdatamodeld

/Users/abc/Documents/Code/xyz-ios/ABC/iPhoneXMPP/SRT/Model.xcdatamodeld

" but "SRT" folder is inside "Temp" folder in my folder structure. How can I resolve this issue?

” 但“SRT”文件夹在我的文件夹结构中的“Temp”文件夹内。我该如何解决这个问题?

采纳答案by redEyeProgrammer

In My Case it was a result of Model.xcdatamodeld having conflicts when Merged with Remote (Source or Head). Somehow this conflict wasn't detected by GIT and slid through as Conflict Free.

在我的案例中,这是 Model.xcdatamodeld 在与远程(源或头)合并时发生冲突的结果。不知何故,这个冲突没有被 GIT 检测到,而是作为无冲突的。

Resolution: Open Model.xcdatamodeld as xml (with textEditor) and search for conflicts (>>>). Fix conflict and Save.

解决方案:打开 Model.xcdatamodeld 作为 xml(使用 textEditor)并搜索冲突 (>>>)。修复冲突并保存。

回答by Tim Newton

Similar to shallowThought's answer, I found I had to first uncheck the target, and then re-check it, and then re-build.

与shallowThought的回答类似,我发现我必须先取消选中目标,然后重新选中它,然后重新构建。

回答by shallowThought

In Xcode, select your Model.xcdatamodeldmodel and tick the checkbox "Target Membership" for your new target in the Inspector.

在 Xcode 中,选择您的Model.xcdatamodeld模型并在 Inspector 中为您的新目标勾选“Target Membership”复选框。

回答by m_katsifarakis

In my case, I had renamed the directory in which my .xcdatamodel resided, which resulted in the old filename entry not being removed from my Target's Compile Sourcesphase.

在我的例子中,我重命名了我的 .xcdatamodel 所在的目录,这导致旧的文件名条目没有从我的目标Compile Sources阶段中删除。

All I had to do was remove the old file from the Compile Sourcesphase, by searching for xcdatamodeldand removing the relevant (now irrelevant...) entry in my target's Build Phasestab:

我所要做的就是从Compile Sources阶段中删除旧文件,方法是在xcdatamodeld目标Build Phases选项卡中搜索并删除相关(现在不相关...)条目:

Remove irrelevant .xcdatamodel files from the <code>Compile Sources</code>phase

从 <code>Compile Sources</code>阶段移除不相关的 .xcdatamodel 文件

  • Don't forget to do this for ALLthe targets that contain your Core Data data model.
  • 不要忘记对包含 Core Data 数据模型的所有目标执行此操作。

Once you're done, make sure that your actual current .xcdatamodeld file is added to your target. You do this:

完成后,请确保将您当前的实际 .xcdatamodeld 文件添加到您的目标中。你做这个:

a)By clicking on the file in Xcode's Project Navigator(left column -> first icon):

a)在 Xcode 的Project Navigator 中点击文件(左栏 -> 第一个图标):

Select your .xcdatamodeld in Xcode's Project Navigator

在 Xcode 的 Project Navigator 中选择您的 .xcdatamodeld

b)And then ticking the boxes of all targets that you want this file to be a part of, in Xcode's File Inspector(right column -> first icon), under Target Membership:

b)然后在 Xcode 的文件检查器(右列 -> 第一个图标)中,在Target Membership以下位置勾选您希望此文件作为其一部分的所有目标的框:

Tick all the targets you want your Core Data model to be a part of

勾选您希望 Core Data 模型成为其一部分的所有目标

回答by Sandeep Singh Rana

In my case in File Selector Code Generation was Selected as Swift. As I selected Code generation language as Objective-C. Error Disappeared.

在我的情况下,文件选择器代码生成被选择为 Swift。因为我选择了代码生成语言作为 Objective-C。错误消失。

After selecting Objective-C

选择Objective-C后

Product > Clean

产品 > 清洁

and then Rebuild the project.

然后重建项目。

This worked for me.

这对我有用。

回答by MrAn3

Just Clean and Build worked for me after adding Core Data manually (not from the start of the project).

在手动添加 Core Data 之后(不是从项目开始),Just Clean and Build 对我有用。

回答by Abz

If you are using NSPersistentContainer, it is available from iOS 10+. You need to change the Target > General > Deployment Info > Deployment Target to 10.0+.

如果您使用的是 NSPersistentContainer,它可从 iOS 10+ 获得。您需要将 Target > General > Deployment Info > Deployment Target 更改为 10.0+。

Then, Product > Clean & Build. It worked.

然后,产品 > 清洁和构建。有效。

回答by NCFUSN

Module Inspector > Module > Current Product Module

模块检查器 > 模块 > 当前产品模块

enter image description here

在此处输入图片说明

Clean and Build afterwards.

清洁和构建之后。

回答by jarora

The answers given above are just right, but if these do not work, then:

上面给出的答案刚刚好,但如果这些都不起作用,那么:

  1. Make a copy of your model and store it somewhere
  2. Delete the model from Xcode
  3. Add the model again to whatever folder you want to add it to
  1. 制作模型的副本并将其存储在某处
  2. 从 Xcode 中删除模型
  3. 再次将模型添加到您要添加到的任何文件夹中

This solved my issue. Hope this helps.

这解决了我的问题。希望这可以帮助。

回答by catanore

In my case I tried to build form an external drive. Copy the project to the internal drive, and it will work.

就我而言,我尝试构建外部驱动器。将项目复制到内部驱动器,它将起作用。