简体   繁体   English

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

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

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. 请看截图。

错误

This problem occurs when the Swift optimization level is not set to None for Release . 斯威夫特优化级别未设置为 释放发生此问题。 Set the value to None and 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 Generation and under Optimization Level make sure Release is set to None . 搜索Swift编译器 - 代码生成并在优化级别下确保将Release设置为None

EDIT 编辑

After upgrading to Xcode 6.1 these instructions caused other issues when archiving (building for debug/device worked fine). 升级到Xcode 6.1后,这些指令在归档时会产生其他问题(构建调试/设备工作正常)。 Setting the optimization to Fastest allowed me to archive again. 将优化设置为Fastest允许我再次存档。 There are apparent issues with Swift compiling still (archiving specifically). Swift编译仍存在明显问题(具体归档)。

Can't archive working 6.0.1 Swift project in Xcode 6.1 / Segmentation fault: 11 无法归档工作6.0.1 Xcode 6.1 /分段故障中的Swift项目:11

EDIT I was not able to fund the Build Settings tab, until I read this answer. 编辑我无法为Build Settings选项卡提供资金,直到我读到这个答案。

how to find the build settings tab 如何查找构建设置选项卡

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个或缺少的文件。

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. 然后,您可以调试最新的错误。

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. 删除这些文件错误将解决。

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)
    }

I don't know if this is really an answer, but... 我不知道这是不是真的答案,但......

I had the same issue. 同样的问题。 App worked when building/running, but archiving failed with "...swiftc failed with exit code 1", with no other helpful message at all. 应用程序在构建/运行时工作,但归档失败,“... swiftc失败,退出代码为1”,没有任何其他有用的消息。 Luckily, when I tried to build my app with Nomad's ipa build , I got: 幸运的是,当我尝试使用Nomad的 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? 因此很明显,编译器要在名为thast元组的元素(按类型定义的tableData )..但仅适用于归档? The Dumb thing is, I use this same pattern in other view controllers, and the compiler seems to be fine with those. 愚蠢的是,我在其他视图控制器中使用相同的模式,编译器似乎很好。

For the record my Code Generation -> Optimization Level was set to None for debug and release. 为了记录,我的Code Generation -> Optimization Level被设置为无以进行调试和发布。

Hope this helps someone! 希望这有助于某人! It took hours to figure this out. 花了几个小时来解决这个问题。

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()

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. 一旦我删除它们,错误就消失了。

This happened to me when I used static inline function from swift file 当我使用swift文件中的静态内联函数时,这发生在我身上

The function looks like this 该功能看起来像这样

static inline void openURLInSafari(NSString * _Nonnull urlString) {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];}

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 重新编译

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. 当我将其设置为UTF-8时,错误消失了。 I think that it was decoding it with the wrong character set. 我认为它是用错误的字符集解码它。

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. 抱歉,这对大多数人来说不是很有帮助,但它可能有助于检查你的角色集。

This error occurred for me after I noticed that a few of my .swift files were inexplicably in the wrong directory -- one level above my Xcode project directory. 我注意到我的一些.swift文件莫名其妙地出现在错误的目录中 - 比我的Xcode项目目录高一级,这对我来说就是这个错误。 When I noticed this, I moved them into the main project directory and cleaned the project, thinking everything would be fine. 当我注意到这一点时,我将它们移动到主项目目录中并清理了项目,认为一切都会好的。 However, upon building the project I got the above-mentioned "failed with exit code 1" error. 但是,在构建项目时,我得到了上述“失败并退出代码1”错误。 Just above the error message it listed the files I had just moved, indicating that it couldn't find them in the directory where they used to be. 在错误消息的正上方,它列出了我刚刚移动的文件,表明它无法在以前的目录中找到它们。 In addition to the error message, the files I moved were now showing up as red in the file navigation pane. 除了错误消息之外,我移动的文件现在在文件导航窗格中显示为红色。

For each of the files in question what I did to resolve this was: - Select the file from the list of files in the Xcode file navigation pane, - Click on the little page icon in the rightmost pane of Xcode, which opens a file attributes pane, - Click on the little folder icon underneath where it says "Location" in the file attributes pane, - Choose the new location for the file, - RESTART Xcode for the above changes to really do anything. 对于每个有问题的文件,我要解决的问题是: - 从Xcode文件导航窗格中的文件列表中选择文件, - 单击Xco​​de最右侧窗格中的小页面图标,打开文件属性窗格, - 单击文件属性窗格中“位置”下方的小文件夹图标, - 选择文件的新位置, - RESTART Xcode,以便上述更改真正做任何事情。

one more case that can lead to this error which just took me hours to track down: a failable initializer that always returns nil. 还有一个案例可以导致这个错误,这个错误花了我几个小时来追踪:一个总是返回nil的可用初始化器。

i had an initializer that looked like this: 我有一个看起来像这样的初始化程序:

init?(object: MyObject) {
    if object.importantProperty {
        // initialize
    }
    return nil
}

when what i meant was: 当我的意思是:

init?(object: MyObject) {
    if object.importantProperty {
        // initialize
    }
    else {
        return nil
    }
}

fixing the initializer made the error go away. 修复初始化程序使错误消失。

If using Core Data : 如果使用Core Data
I had a Core Data entity for which I created the NSManagedObject subclasses (with Xcode's help). 我有一个Core Data实体,我为其创建了NSManagedObject子类(使用Xcode的帮助)。 In addition, the entity was configured to generate code automatically (see screenshot), so basically 2 classes existed during runtime. 此外,实体配置为自动生成代码(参见屏幕截图),因此在运行时基本上存在2个类。 Just switch the option to Manual/None and it won't generate it. 只需将选项切换到手动/无,它就不会生成它。

在此输入图像描述

I experienced this error after performing a git merge. 执行git merge后我遇到了这个错误。 I solved new Xcode warnings and the project can be compiled. 我解决了新的Xcode警告,可以编译项目。

Xcode 7.2.1 is used in my case. 在我的例子中使用Xcode 7.2.1。

In my way the error was due to UIDevice.currentDevice() in ((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0) 以我的方式,错误是由于UIDevice.currentDevice()((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0)

After commenting this all starts work fine. 评论后,所有开始工作正常。

XCode 7.2 XCode 7.2

在我的情况下,在你的项目目标Build Setttings,在其他Swift标志中,jsut删除字符串“-serialize-debuggin-options” 在这里输入图像描述

In my case, the error was the result of missing files that were generated by Xcode. 在我的情况下,错误是由Xcode生成的丢失文件的结果。 I tried the regular clean Opt + Shift + K and it didn't clean up all the errors. 我尝试了常规的清洁Opt + Shift + K ,它没有清除所有错误。 I found a post on the Apple Developer site that recomended going to the Product Menu in Xcode, holding down the opt key, and selecting Clean Build Folder. 我在Apple Developer网站上发现了一篇帖子,建议转到Xcode的Product Menu,按住opt键,然后选择Clean Build Folder。 This appears to be a more comprehensive build as it pops up a modal dialog for you to confirm. 这似乎是一个更全面的构建,因为它会弹出一个模式对话框供您确认。

I had a resolution very similar to RyanM , where with an excess of hubris I tried to assign a variable to the default value of an inner function: 我有一个非常类似于RyanM的分辨率,其中有过多的傲慢,我试图将变量赋值给内部函数的默认值:

Fails to compile (though does not crash SourceKit): 无法编译(虽然不会导致SourceKit崩溃):

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    func itemCell(_ indexPath: IndexPath = indexPath) -> UITableViewCell {//...}

Succeeds: 成功:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    func itemCell(_ indexPath: IndexPath) -> UITableViewCell {//...}

One possible reason that this can happen is perhaps because you have deleted a file but not removed references to it. 可能发生这种情况的一个可能原因可能是因为您删除了一个文件但没有删除对它的引用。 This will mess up the pbxproj file. 这会弄乱pbxproj文件。 I would check to see if that is the case. 我会检查是否是这种情况。

检查“Development Pods”文件夹中列出的所有Frameworks路径。

In my case swift development snapshot was selected instead of xcode 9.2. 在我的例子中,选择了快速开发快照而不是xcode 9.2。 here are the steps and image. 这是步骤和图像。

  1. keep xcode on screen and click on xcode top menu bar. 将xcode保留在屏幕上,然后单击xcode顶部菜单栏。
  2. Than go to toolchains option and check on xcode 9.2. 比去工具链选项并检查xcode 9.2。 thats it. 而已。 在此输入图像描述 Happy Coding!!! 快乐的编码!!!

So, I had the above and narrowed it down to a TFS issue with locking the file but only when I pasted or did any other edits besides small copies or manual typing. 所以,我有上述内容,并将其缩小到TFS问题,锁定文件,但只有当我粘贴或进行除小副本或手动输入之外的任何其他编辑。 I noticed the original file would compile, but my edits wouldn't, even though they were syntactic OK. 我注意到原始文件会编译,但我的编辑不会,即使它们语法正常。 Also related is unable to save document: xcode The document "..." could not be saved 还相关无法保存文档: xcode无法保存文档“...”

The fix for both was: 两者的解决方案是:

  1. Duplicate working version. 重复的工作版本。
  2. Paste fully-merged new code into duplicate. 将完全合并的新代码粘贴到重复内容中。
  3. Copy and paste old file over new one. 将旧文件复制并粘贴到新文件上。 (I personally just renamed the old one to something else, then pasted duplicate and renamed it, too. Guessing both work since I pasted directly earlier for reverts during tests to see). (我个人只是将旧的重命名为其他内容,然后粘贴副本并将其重命名。猜测两者都有效,因为我在测试期间直接粘贴以便恢复)。

Voila. 瞧。 Lazy way to bypass merge-locking issue. 懒惰的方式绕过合并锁定问题。 Apparently full file-pastes are just fine, while edits aren't. 显然,完整的文件粘贴很好,而编辑则不行。 Shared since the other answers don't seem to be as lazy as this. 共享,因为其他答案似乎并不像这样懒。 ;) Note: I am suspecting a non-UTF-8 character made its way somewhere, but pastes worked in older versions so I don't know where, or if relevant. ;)注意:我怀疑非UTF-8字符在某处出现,但是粘贴在旧版本中工作,因此我不知道在哪里或相关。

只需转到“项目设置”并单击“构建阶段”,之后您将找到目标,因为您必须删除测试文件,如项目名称“WER”,因此它显示为WER&TEST,所以只需删除并清理你的项目和运行.........

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Xcode 7失败,命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc失败,退出代码为1 - Xcode 7 fails with Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 XCode - 命令 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc 失败,退出代码 1 - XCode - 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 - Error: 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 - Error — Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 Xcode 8.0 命令 /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc 失败,退出代码为 1 - Xcode 8.0 Command /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 命令 /Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang 失败,退出代码为 1 - Command /Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1 生成失败并显示错误命令/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 命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang失败,退出代码为1 - Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1 Swift编译器错误:命令/Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc失败,退出代码为6 - Swift Compiler Error : Command /Applications/Xcode9.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 6 Bridging-header.h导致命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc失败,退出代码为1 - Bridging-header.h causes Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM