生成失败并显示错误命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc [英] Build failed with error Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc

查看:1091
本文介绍了生成失败并显示错误命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 8.2.1。我也在我的项目中使用CoreData。
尝试生成内部版本或存档时,出现以下错误。错误中提到的文件有时也会更改。

I am using Xcode 8.2.1. I am also using CoreData in my project. When I try to generate a build or when I archive I am seeing the following error. Files mentioned in the error also changes at times.

错误:

<unknown>:0: error: no such file or directory: '/Users/anuragparashar/Library/Developer/Xcode/DerivedData/app-drgjxhipxxqdrcatqfdgpayyxnud/Build/Intermediates/app.build/Debug-iphoneos/app.build/DerivedSources/CoreDataGenerated/app/BuildingRoofMapping+CoreDataClass.swift'
<unknown>:0: error: no such file or directory: '/Users/anuragparashar/Library/Developer/Xcode/DerivedData/app-drgjxhipxxqdrcatqfdgpayyxnud/Build/Intermediates/app.build/Debug-iphoneos/app.build/DerivedSources/CoreDataGenerated/app/BuildingRoofMapping+CoreDataProperties.swift'
<unknown>:0: error: no such file or directory: '/Users/anuragparashar/Library/Developer/Xcode/DerivedData/app-drgjxhipxxqdrcatqfdgpayyxnud/Build/Intermediates/app.build/Debug-iphoneos/app.build/DerivedSources/CoreDataGenerated/app/Region+CoreDataClass.swift'
<unknown>:0: error: no such file or directory: '/Users/anuragparashar/Library/Developer/Xcode/DerivedData/app-drgjxhipxxqdrcatqfdgpayyxnud/Build/Intermediates/app.build/Debug-iphoneos/app.build/DerivedSources/CoreDataGenerated/app/Region+CoreDataProperties.swift'
<unknown>:0: error: no such file or directory: '/Users/anuragparashar/Library/Developer/Xcode/DerivedData/app-drgjxhipxxqdrcatqfdgpayyxnud/Build/Intermediates/app.build/Debug-iphoneos/app.build/DerivedSources/CoreDataGenerated/app/StateRegionMapping+CoreDataProperties.swift'
<unknown>:0: error: no such file or directory: '/Users/anuragparashar/Library/Developer/Xcode/DerivedData/app-drgjxhipxxqdrcatqfdgpayyxnud/Build/Intermediates/app.build/Debug-iphoneos/app.build/DerivedSources/CoreDataGenerated/app/WalkingDoors+CoreDataClass.swift'
<unknown>:0: error: no such file or directory: '/Users/anuragparashar/Library/Developer/Xcode/DerivedData/app-drgjxhipxxqdrcatqfdgpayyxnud/Build/Intermediates/app.build/Debug-iphoneos/app.build/DerivedSources/CoreDataGenerated/app/WalkingDoors+CoreDataProperties.swift'
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

以下是配置我的CoreData实体的方式:

我尝试过的事情:


  1. 检查位置以查看是否确实缺少文件,文件是否存在于同一路径。

  2. 我清理了构建文件夹并删除派生数据,然后重新构建。没有任何帮助。

  3. 尝试了该链接

  4. 问题似乎也不起作用。

  1. Check the location to see if files are actually missing, Files where present exactly at the same path.
  2. I cleaned the build folder and removed derived data and build it again. Nothing helped.
  3. Tried all the answers in this link. Nothing Worked.
  4. Accepted Answer of this question doesn't seem to work either.

我不确定为什么会出现此错误。

I am not sure why this error is coming. Any help is appreciated

EDIT

如果我从代码中完全删除了CoreData,将不胜感激然后成功存档。

If I completely remove CoreData from my code then it Archives Successfully.

编辑2:

当我将CodeGen更改为Manual / None并添加 @建议的手动文件阿尼尔。它可以成功构建,但是当我尝试使用以下方法获取CoreData实体时:

When I change CodeGen to Manual/None and add files manually as suggested by @Anil . It builds successfully, But when I try to fetch the CoreData entity using :

let context = appDelegate.persistentContainer.viewContext
let buildingRoofMapping = BuildingRoofMapping(context:context)

这给了我运行时错误。
错误:

It gives me run time error. Error :

'NSInvalidArgumentException', reason: 'An NSManagedObject of class 'BuildingRoofMapping' must have a valid NSEntityDescription.'

编辑3:
示例代码链接。在模拟器中运行。它在ViewController.swift文件的fetchBasicPrice()中崩溃

EDIT 3: Sample Code link. Run it in simulator. It crashes in fetchBasicPrice() of ViewController.swift file

推荐答案

以下对我有用的步骤:


  1. 按照 Anil的答案,适用于所有实体。

  2. 手动创建CoreData文件。对于每个实体,将创建两个文件。

  1. Change Module to Current Product Module and Codegen to Manual/None as suggested in Anil's Answer, for ALL the entities.
  2. Manually Create CoreData files. For every entity two files are created.


  • 其中一个是EntityName + CoreData,其内容如下:

  • One will be EntityName+CoreData with below contents :

    import Foundation
    import CoreData

    public class EntityName: NSManagedObject {
    }


  • 另一个将被命名为:EntityName + Properties

  • another will be named : EntityName+Properties

    import Foundation
    import CoreData
    
    extension BasicPrice {
         @nonobjc public class func fetchRequest() -> NSFetchRequest<BasicPrice> {
         return NSFetchRequest<BasicPrice>(entityName: "BasicPrice");}
    
       @NSManaged public var var1 : String?
       @NSManaged public var var2 : Int32
       @NSManaged public var var3 : Float
       @NSManaged public var var4 : Bool
     }
    


  • 注意:
    这种类/结构不是我开发的,当我们从CodeGen中选择类定义时,内部会紧随其后的是CoreData。

    NOTE: This kind of class/structure is not my developed, it is followed by CoreData internally when we select Class Definition from CodeGen.

    希望它对某人有帮助!

    Hope it helps someone!

    这篇关于生成失败并显示错误命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆