我正在运行xCode版本10.1(10B61),Mojave 10.14(18A391)

搜索结果显示,Xcode 10中的类似问题比一年前更严重,但从那以后就没有问题了.go 年的解决方案似乎是切换到传统模式,但现在不行了.我的桌面上存储的源代码似乎与"DerivedData"中的代码冲突,我不确定为什么会突然如此随机地弹出.

如果删除核心数据中添加的最后一个模型,我会发现这个问题消失了.当我向另一个对象添加关系时,它似乎会触发.这显然是随机的.

有什么建议可以帮助我解决这个问题吗?

Multiple commands produce '//Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/Objects-normal/x86_64/Contact+CoreDataClass.o':

Target 'ProjectCoreData' (project 'ProjectCoreData') has compile command for Swift source files

Target 'ProjectCoreData' (project 'ProjectCoreData') has compile command for Swift source files

从日志(log)中:

<unknown>:0: error: filename "Contact+CoreDataClass.swift" used twice: '/Users/<user>/Desktop/ProjectCoreData/Contact+CoreDataClass.swift' and '/Users/<user>/Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/DerivedSources/CoreDataGenerated/ProjectCoreData/Contact+CoreDataClass.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
<unknown>:0: error: filename "Contact+CoreDataProperties.swift" used twice: '/Users/<user>/Desktop/ProjectCoreData/Contact+CoreDataProperties.swift' and '/Users/<user>/Library/Developer/Xcode/DerivedData/ProjectCoreData-ehjvvgovpitmbcegzopwciptfafr/Build/Intermediates.noindex/ProjectCoreData.build/Debug-iphonesimulator/ProjectCoreData.build/DerivedSources/CoreDataGenerated/ProjectCoreData/Contact+CoreDataProperties.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

推荐答案

出现此错误的原因是,默认情况下,Core Data会创建这些文件,但在Project Navigator中看不到它们.然后创建一个副本(在编辑器/create NSManagedObject子类中).结果你犯了错误.

根据What's new in Core Data,下面是一张带有解决方案的图片:

Picture with solution

Swift相关问答推荐

Swift-Can无法在AudioKit中找出简单的麦克风效果-文件链

如何在每天午夜重置布尔值

通常从数组调用的SWIFT静态协议函数

使用MKLocalSearch获取坐标

String.Index encodedOffset已弃用,但建议的替代方案不起作用

从任务中打印

SwiftUI,如何更改具有多个按钮和一个布尔条件的一个按钮标签

在 Swift 中将异步任务包装到 DispatchWorkItem 中以使其可取消?

CardStack 和 Lottie

如何在 Swift 中对单个单词进行词形还原

按钮图像不会立即刷新

如何确定扩展中的具体类型?

在 Swift 4 中实现自定义解码器

我可以在 Swift 中为泛型类型 T 分配默认类型吗?

如何使用 swift 将 Images.xcassets 中的图像加载到 UIImage 中

如何从一个可观察的数组创建一个可观察的数组?

为 UIImagePicker 设置委托返回错误

两个 Date 对象之间的所有日期 (Swift)

如何在 Swift 中重写 setter

如何将多个枚举值作为函数参数传递