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
Could not determine generated file paths for CoreData code generation
提问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.xcdatamodeld
model 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 Sources
phase.
在我的例子中,我重命名了我的 .xcdatamodel 所在的目录,这导致旧的文件名条目没有从我的目标Compile Sources
阶段中删除。
All I had to do was remove the old file from the Compile Sources
phase, by searching for xcdatamodeld
and removing the relevant (now irrelevant...) entry in my target's Build Phases
tab:
我所要做的就是从Compile Sources
阶段中删除旧文件,方法是在xcdatamodeld
目标Build Phases
选项卡中搜索并删除相关(现在不相关...)条目:
- 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 中点击文件(左栏 -> 第一个图标):
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
以下位置勾选您希望此文件作为其一部分的所有目标的框:
回答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
回答by jarora
The answers given above are just right, but if these do not work, then:
上面给出的答案刚刚好,但如果这些都不起作用,那么:
- Make a copy of your model and store it somewhere
- Delete the model from Xcode
- Add the model again to whatever folder you want to add it to
- 制作模型的副本并将其存储在某处
- 从 Xcode 中删除模型
- 再次将模型添加到您要添加到的任何文件夹中
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.
就我而言,我尝试构建外部驱动器。将项目复制到内部驱动器,它将起作用。