ios Xcode 6.0.1 命令 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc 失败,退出代码为 1

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

Xcode 6.0.1 Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

iosios8xcode6.0.1

提问by R_Developer

I am getting this error on archive:

我在存档中收到此错误:

Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1

命令 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc 失败,退出代码为 1

How to solve it?

如何解决?

Please see the screenshot.

请看截图。

error

错误

回答by Mark McCorkle

This problem occurs when the Swift optimization levelis not set to Nonefor Release. Set the value to Noneand the issue goes away.

当出现此问题斯威夫特优化级别未设置为版本。将值设置为,问题就会消失。

  1. Open up your project and click on the projects root directory.
  2. Click the build settings tab.
  3. Search for Swift Compiler - Code Generationand under Optimization Levelmake sure Releaseis set to None.
  1. 打开您的项目并单击项目根目录。
  2. 单击构建设置选项卡。
  3. 搜索Swift Compiler - Code Generation并在Optimization Level下确保Release设置为None

EDIT

编辑

After upgrading to Xcode 6.1 these instructions caused other issues when archiving (building for debug/device worked fine). Setting the optimization to Fastest allowed me to archive again. There are apparent issues with Swift compiling still (archiving specifically).

升级到 Xcode 6.1 后,这些说明在存档时导致了其他问题(为调试/设备构建工作正常)。将优化设置为最快允许我再次存档。Swift 编译仍然存在明显的问题(特别是归档)。

Can't archive working 6.0.1 Swift project in Xcode 6.1 / Segmentation fault: 11

无法在 Xcode 6.1 中归档工作 6.0.1 Swift 项目/分段错误:11

EDITI was not able to fund the Build Settings tab, until I read this answer.

编辑在我阅读此答案之前,我无法为“构建设置”选项卡提供资金。

how to find the build settings tab

如何找到构建设置选项卡

回答by Henry F

This occurred for me when I had two of the exact same files, and also when I was missing I file I didn't know I had deleted. I clicked on the error message, and just above the error, it shows you what file you have more than 1 of or are missing.

当我有两个完全相同的文件时,就会发生这种情况,而且当我丢失了我不知道已删除的文件时。我点击了错误消息,就在错误上方,它会显示您拥有超过 1 个或丢失的文件。

回答by u5211732

You can click the Product in the navigation and choose the "Clean" button; it will clean all compile error in your project. Then, you can debug for the latest error.

您可以点击导航中的产品并选择“清洁”按钮;它将清除您项目中的所有编译错误。然后,您可以调试最新的错误。

回答by FARAZ

Deleted files reference keep in Build Phase and that's why it gives this error. Remove reference from there as well.

删除的文件引用保留在构建阶段,这就是它给出此错误的原因。也从那里删除引用。

Project> Target > Build Phase

项目>目标>构建阶段

Under this section you will find your deleted files in red colour. Remove these files error will resolve.

在此部分下,您会发现已删除的文件呈红色。删除这些文件错误将解决。

回答by Mihriban Minaz

I am not sure if it has one solution. I recommend you to check the differences between your last git commit, and comment on/off the changes.

我不确定它是否有一种解决方案。我建议您检查上次 git 提交之间的差异,并对更改进行评论。

In my case, my code was

就我而言,我的代码是

let anArray = ResultDict["ResultSet"] as [[NSDictionary : AnyObject]]
for aDict : NSDictionary in anArray {
    let anObject = ObjectType(ObjectDict: aDict)
    objectList.addObject(aDict)
}

no warning on the line, i got the same exit 1 compile error then i changed it to the below it has compiled.

在线没有警告,我得到了相同的退出 1 编译错误,然后我将其更改为它已编译的以下内容。

let anArray = ResultDict["ResultSet"] as [[NSDictionary : AnyObject]]
    for aDict in anArray {
        let anObject = ObjectType(ObjectDict: aDict)
        objectList.addObject(aDict)
    }

回答by RyanM

I don't know if this is really an answer, but...

我不知道这是否真的是一个答案,但是......

I hadthe same issue. App worked when building/running, but archiving failed with "...swiftc failed with exit code 1", with no other helpful message at all. Luckily, when I tried to build my app with Nomad'sipa build, I got:

同样的问题。应用程序在构建/运行时工作,但归档失败,“...swiftc failed with exit code 1”,根本没有其他有用的消息。幸运的是,当我尝试使用Nomad's构建我的应用程序时ipa build,我得到了:

The following build commands failed:
    CompileSwift normal arm64 /path/to/erroneous/TableViewController.swift

So I started commenting out sections of that file and tracked the problem down to a tuple assignment.

所以我开始注释掉那个文件的部分并将问题追踪到一个元组分配。

// MARK: - Table Data

private var tableData: [(sectionName: String, item:ListItem)] = []

private func refreshTableData() {

    // let labor = ("Labor", laborListItem)                 // DOESN'T ARCHIVE
    let labor = (sectionName: "Labor", item: laborListItem) // ARCHIVES

    tableData = [labor]

    tableView.reloadData()
}

So apparently the compiler wanted the elements in thast tuple named (as defined by the type of tableData).. but only for archiving? The Dumb thing is, I use this same pattern in other view controllers, and the compiler seems to be fine with those.

显然,编译器希望元组中的元素命名(由tableData..的类型定义)但仅用于存档?愚蠢的事情是,我在其他视图控制器中使用了相同的模式,而编译器似乎对这些模式没问题。

For the record my Code Generation -> Optimization Levelwas set to None for debug and release.

为了记录我Code Generation -> Optimization Level被设置为 None 进行调试和发布。

Hope this helps someone! It took hours to figure this out.

希望这可以帮助某人!花了几个小时才弄清楚这一点。

回答by danywarner

It happened to me when I didn't put the parenthesis at the end of a call of a function:

当我没有将括号放在函数调用的末尾时,它发生在我身上:

let var = self.getNextPrimeNumber

solved it by:

通过以下方式解决:

let var = self.getNextPrimeNumber()

回答by Dimitri T

In my case, it was caused by duplicate files, using the same name, in my project directory. As soon as I removed them, the error was gone.

就我而言,它是由我的项目目录中使用相同名称的重复文件引起的。一旦我删除它们,错误就消失了。

回答by Jane chicken

this error comes from missing files so the compiler couldn't find the files and keep alerting. Follow these steps to rebuild your app:

此错误来自缺少文件,因此编译器找不到文件并保持警报。请按照以下步骤重建您的应用程序:

  1. Look up for the red and invisible files within workspace
  2. Remove their reference
  3. Re-add files
  4. Re-compile
  1. 在工作区中查找红色和不可见文件
  2. 删除他们的参考
  3. 重新添加文件
  4. 重新编译

回答by Owen Godfrey

I just had the same thing occur. I hunted down the cause to one file that caused the error even when empty. Examining the file, I discovered it had the wrong character set. When I set it to UTF-8, the error vanished. I think that it was decoding it with the wrong character set.

我刚刚发生了同样的事情。我找到了一个导致错误的文件的原因,即使是空的。检查文件,我发现它有错误的字符集。当我将其设置为 UTF-8 时,错误消失了。我认为它使用错误的字符集对其进行了解码。

From this I surmise that the error simply indicates that something has happened that the compiler was unprepared for. Sorry that isn't very helpful to most people, but it may help to check your characters sets.

由此我推测该错误只是表明发生了一些编译器没有准备好的事情。抱歉,这对大多数人不是很有帮助,但它可能有助于检查您的字符集。