Xcode 6.0.1中命令/应用程序/ Xcode /内容/开发/工具链/ XcodeDefault。xctoolchain/usr/bin/swiftc失败,退出代码1

时间:2023-01-22 18:19:45

please help me with the error.

请帮我改正错误。

I am stuck badly, tried solving the error but didn't work for me.

我被困住了,试图解决这个错误,但没有成功。

Need help ....

需要帮助....

Please see the screenshot.

请见截图。

Xcode 6.0.1中命令/应用程序/ Xcode /内容/开发/工具链/ XcodeDefault。xctoolchain/usr/bin/swiftc失败,退出代码1

I am getting this error on archive.

我在存档中得到了这个错误。

24 个解决方案

#1


98  

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.

当Swift优化级别没有设置为None时,就会出现这个问题。将值设为None,问题就会消失。

  1. Open up your project and click on the projects root directory.
  2. 打开项目并单击projects根目录。
  3. Click the build settings tab.
  4. 单击build settings选项卡。
  5. Search for Swift Compiler - Code Generation and under Optimization Level make sure Release is set to None.
  6. 搜索Swift编译器代码生成和在优化级别下确保释放设置为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之后,这些指令在归档时引起了其他问题(为调试/设备构建)。将优化设置为最快允许我再次归档。快速编译仍然存在明显的问题(特别是存档)。

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

无法在Xcode 6.1 /分割错误中存档工作6.0.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

如何找到build settings选项卡

#2


34  

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个或正在丢失的文件。

#3


16  

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.

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

#4


8  

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.

在本节中,您将发现已删除的文件是红色的。删除这些文件将解决错误。

#5


4  

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

#6


3  

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. Luckily, when I tried to build my app with Nomad's ipa build, I got:

我有同样的问题。App在构建/运行时起作用,但归档失败。swiftc失败了退出代码1“,没有任何其他有用的信息。幸运的是,当我尝试用Nomad的ipa构建我的应用时,我得到了:

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.

显然,编译器想要命名为的ast元组中的元素(由表数据类型定义)。但只有存档吗?愚蠢的是,我在其他视图控制器中使用了相同的模式,编译器似乎对这些没有问题。

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

对于记录,我的代码生成—>优化级别被设置为None进行调试和发布。

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

希望这可以帮助别人!花了几个小时才弄明白。

#7


3  

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

#8


3  

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.

在我的例子中,它是由重复的文件,在我的项目目录中使用相同的名称造成的。我一去掉它们,错误就消失了。

#9


1  

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]];}

#10


1  

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。编译

#11


1  

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.

由此我推测,这个错误仅仅表明发生了编译器没有准备好的事情。对不起,这对大多数人来说并不是很有帮助,但它可能有助于检查您的字符集。

#12


1  

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. 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. 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.

我注意到我的一些.swift文件莫名其妙地放在了错误的目录中——比我的XCode项目目录高一级。当我注意到这一点时,我将它们移动到主项目目录并清理项目,认为一切都会很好。然而,在构建项目时,我得到了上面提到的“退出代码1失败”的错误。就在错误消息的上方,它列出了我刚才移动的文件,表明它无法在原来的目录中找到它们。除了错误消息之外,我移动的文件现在在文件导航窗格中显示为红色。

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文件导航窗格中,——点击XCode的小页面图标在右边的窗格中,打开一个文件属性窗格,——点击下面的文件夹图标,它说“位置”文件属性窗格中,-选择新位置的文件,重启XCode上述变化真的做任何事。

#13


1  

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.

修复初始化程序使错误消失。

#14


1  

If using Core Data:
I had a Core Data entity for which I created the NSManagedObject subclasses (with Xcode's help). In addition, the entity was configured to generate code automatically (see screenshot), so basically 2 classes existed during runtime. Just switch the option to Manual/None and it won't generate it.

如果使用Core Data:我有一个Core Data实体,我为它创建了NSManagedObject子类(在Xcode的帮助下)。此外,实体被配置为自动生成代码(参见屏幕截图),因此基本上在运行时存在两个类。只需将选项切换到Manual/None,它就不会生成它。

Xcode 6.0.1中命令/应用程序/ Xcode /内容/开发/工具链/ XcodeDefault。xctoolchain/usr/bin/swiftc失败,退出代码1

#15


0  

I experienced this error after performing a git merge. I solved new Xcode warnings and the project can be compiled.

在执行git合并后,我经历了这个错误。我解决了新的Xcode警告,可以编译这个项目。

Xcode 7.2.1 is used in my case.

Xcode 7.2.1在我的例子中使用。

#16


0  

In my way the error was due to UIDevice.currentDevice() in ((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0)

在我看来,这个错误是由于(UIDevice.currentDevice)中的UIDevice.currentDevice()造成的。systemVersion NSString)。floatValue > = 8.0)

After commenting this all starts work fine.

在评论完这些之后,一切都开始正常工作了。

XCode 7.2

XCode 7.2

#17


0  

in my case , at your project target Build Setttings, in Other Swift Flags,jsut delete the String "-serialize-debuggin-options" enter image description here

在我的例子中,在您的项目目标构建Setttings,迅速在其他旗帜,只是删除字符串“-serialize-debuggin-options”在这里输入图像描述

#18


0  

In my case, the error was the result of missing files that were generated by Xcode. I tried the regular clean Opt+Shift+K and it didn't clean up all the errors. 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. This appears to be a more comprehensive build as it pops up a modal dialog for you to confirm.

在我的例子中,错误是Xcode生成的丢失文件的结果。我尝试了常规的clean Opt+Shift+K,但并没有清除所有的错误。我在苹果开发者网站上找到了一篇文章,内容是在Xcode的产品菜单上,按住opt键,选择Clean Build文件夹。这似乎是一个更全面的构建,因为它弹出一个模态对话框供您确认。

#19


0  

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 {//...}

#20


0  

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. I would check to see if that is the case.

发生这种情况的一个可能原因可能是您删除了一个文件,但没有删除对它的引用。这会打乱pbxproj文件。我会检查一下是否有这种情况。

#21


0  

check "Development Pods" Folder all listed Frameworks path.

检查“开发豆荚”文件夹所有列出的框架路径。

#22


0  

In my case swift development snapshot was selected instead of xcode 9.2. here are the steps and image.

在我的例子中,选择了swift开发快照,而不是xcode 9.2。这里是步骤和图像。

  1. keep xcode on screen and click on xcode top menu bar.
  2. 保持xcode在屏幕上,点击xcode顶部菜单栏。
  3. Than go to toolchains option and check on xcode 9.2. thats it. Xcode 6.0.1中命令/应用程序/ Xcode /内容/开发/工具链/ XcodeDefault。xctoolchain/usr/bin/swiftc失败,退出代码1 Happy Coding!!!
  4. 而不是使用工具链选项并检查xcode 9.2。这是它。编码快乐! ! !

#23


0  

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. 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

因此,我把上面的内容缩小到一个TFS问题,即锁定文件,但只有在粘贴或进行除小拷贝或手动输入之外的任何其他编辑时才会这样。我注意到原始文件会被编译,但是我的编辑不会,即使它们是语法上的。也相关文件无法保存:xcode文件“…”无法保存

The fix for both was:

两者的解决方案是:

  1. Duplicate working version.
  2. 重复的工作版本。
  3. Paste fully-merged new code into duplicate.
  4. 将完全合并的新代码粘贴到副本中。
  5. 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).
  6. 将旧文件复制粘贴到新文件上。(我个人只是把旧的重命名为其他的东西,然后粘贴复制并重命名它。猜测这两项工作,因为我在测试期间直接粘贴了恢复以查看)。

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字符在某个地方出现,但粘贴在旧版本中,所以我不知道它在哪里,或者是否相关。

#24


-1  

Just go to the "project setting" and click on the "build phaces" after that you will find targets in that u have to delete the test file like my project name "WER" so its showing like this WER&TEST so just delete that and clean ur project and run .........

进入“项目设置”,点击“构建阶段”之后,你就会发现你需要删除测试文件,比如我的项目名称“WER”,这样它的显示就像这个WER&TEST一样,所以只要删除它,清理你的项目,然后运行它。

#1


98  

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.

当Swift优化级别没有设置为None时,就会出现这个问题。将值设为None,问题就会消失。

  1. Open up your project and click on the projects root directory.
  2. 打开项目并单击projects根目录。
  3. Click the build settings tab.
  4. 单击build settings选项卡。
  5. Search for Swift Compiler - Code Generation and under Optimization Level make sure Release is set to None.
  6. 搜索Swift编译器代码生成和在优化级别下确保释放设置为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之后,这些指令在归档时引起了其他问题(为调试/设备构建)。将优化设置为最快允许我再次归档。快速编译仍然存在明显的问题(特别是存档)。

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

无法在Xcode 6.1 /分割错误中存档工作6.0.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

如何找到build settings选项卡

#2


34  

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个或正在丢失的文件。

#3


16  

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.

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

#4


8  

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.

在本节中,您将发现已删除的文件是红色的。删除这些文件将解决错误。

#5


4  

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

#6


3  

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. Luckily, when I tried to build my app with Nomad's ipa build, I got:

我有同样的问题。App在构建/运行时起作用,但归档失败。swiftc失败了退出代码1“,没有任何其他有用的信息。幸运的是,当我尝试用Nomad的ipa构建我的应用时,我得到了:

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.

显然,编译器想要命名为的ast元组中的元素(由表数据类型定义)。但只有存档吗?愚蠢的是,我在其他视图控制器中使用了相同的模式,编译器似乎对这些没有问题。

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

对于记录,我的代码生成—>优化级别被设置为None进行调试和发布。

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

希望这可以帮助别人!花了几个小时才弄明白。

#7


3  

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

#8


3  

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.

在我的例子中,它是由重复的文件,在我的项目目录中使用相同的名称造成的。我一去掉它们,错误就消失了。

#9


1  

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]];}

#10


1  

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。编译

#11


1  

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.

由此我推测,这个错误仅仅表明发生了编译器没有准备好的事情。对不起,这对大多数人来说并不是很有帮助,但它可能有助于检查您的字符集。

#12


1  

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. 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. 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.

我注意到我的一些.swift文件莫名其妙地放在了错误的目录中——比我的XCode项目目录高一级。当我注意到这一点时,我将它们移动到主项目目录并清理项目,认为一切都会很好。然而,在构建项目时,我得到了上面提到的“退出代码1失败”的错误。就在错误消息的上方,它列出了我刚才移动的文件,表明它无法在原来的目录中找到它们。除了错误消息之外,我移动的文件现在在文件导航窗格中显示为红色。

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文件导航窗格中,——点击XCode的小页面图标在右边的窗格中,打开一个文件属性窗格,——点击下面的文件夹图标,它说“位置”文件属性窗格中,-选择新位置的文件,重启XCode上述变化真的做任何事。

#13


1  

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.

修复初始化程序使错误消失。

#14


1  

If using Core Data:
I had a Core Data entity for which I created the NSManagedObject subclasses (with Xcode's help). In addition, the entity was configured to generate code automatically (see screenshot), so basically 2 classes existed during runtime. Just switch the option to Manual/None and it won't generate it.

如果使用Core Data:我有一个Core Data实体,我为它创建了NSManagedObject子类(在Xcode的帮助下)。此外,实体被配置为自动生成代码(参见屏幕截图),因此基本上在运行时存在两个类。只需将选项切换到Manual/None,它就不会生成它。

Xcode 6.0.1中命令/应用程序/ Xcode /内容/开发/工具链/ XcodeDefault。xctoolchain/usr/bin/swiftc失败,退出代码1

#15


0  

I experienced this error after performing a git merge. I solved new Xcode warnings and the project can be compiled.

在执行git合并后,我经历了这个错误。我解决了新的Xcode警告,可以编译这个项目。

Xcode 7.2.1 is used in my case.

Xcode 7.2.1在我的例子中使用。

#16


0  

In my way the error was due to UIDevice.currentDevice() in ((UIDevice.currentDevice().systemVersion as NSString).floatValue >= 8.0)

在我看来,这个错误是由于(UIDevice.currentDevice)中的UIDevice.currentDevice()造成的。systemVersion NSString)。floatValue > = 8.0)

After commenting this all starts work fine.

在评论完这些之后,一切都开始正常工作了。

XCode 7.2

XCode 7.2

#17


0  

in my case , at your project target Build Setttings, in Other Swift Flags,jsut delete the String "-serialize-debuggin-options" enter image description here

在我的例子中,在您的项目目标构建Setttings,迅速在其他旗帜,只是删除字符串“-serialize-debuggin-options”在这里输入图像描述

#18


0  

In my case, the error was the result of missing files that were generated by Xcode. I tried the regular clean Opt+Shift+K and it didn't clean up all the errors. 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. This appears to be a more comprehensive build as it pops up a modal dialog for you to confirm.

在我的例子中,错误是Xcode生成的丢失文件的结果。我尝试了常规的clean Opt+Shift+K,但并没有清除所有的错误。我在苹果开发者网站上找到了一篇文章,内容是在Xcode的产品菜单上,按住opt键,选择Clean Build文件夹。这似乎是一个更全面的构建,因为它弹出一个模态对话框供您确认。

#19


0  

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 {//...}

#20


0  

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. I would check to see if that is the case.

发生这种情况的一个可能原因可能是您删除了一个文件,但没有删除对它的引用。这会打乱pbxproj文件。我会检查一下是否有这种情况。

#21


0  

check "Development Pods" Folder all listed Frameworks path.

检查“开发豆荚”文件夹所有列出的框架路径。

#22


0  

In my case swift development snapshot was selected instead of xcode 9.2. here are the steps and image.

在我的例子中,选择了swift开发快照,而不是xcode 9.2。这里是步骤和图像。

  1. keep xcode on screen and click on xcode top menu bar.
  2. 保持xcode在屏幕上,点击xcode顶部菜单栏。
  3. Than go to toolchains option and check on xcode 9.2. thats it. Xcode 6.0.1中命令/应用程序/ Xcode /内容/开发/工具链/ XcodeDefault。xctoolchain/usr/bin/swiftc失败,退出代码1 Happy Coding!!!
  4. 而不是使用工具链选项并检查xcode 9.2。这是它。编码快乐! ! !

#23


0  

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. 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

因此,我把上面的内容缩小到一个TFS问题,即锁定文件,但只有在粘贴或进行除小拷贝或手动输入之外的任何其他编辑时才会这样。我注意到原始文件会被编译,但是我的编辑不会,即使它们是语法上的。也相关文件无法保存:xcode文件“…”无法保存

The fix for both was:

两者的解决方案是:

  1. Duplicate working version.
  2. 重复的工作版本。
  3. Paste fully-merged new code into duplicate.
  4. 将完全合并的新代码粘贴到副本中。
  5. 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).
  6. 将旧文件复制粘贴到新文件上。(我个人只是把旧的重命名为其他的东西,然后粘贴复制并重命名它。猜测这两项工作,因为我在测试期间直接粘贴了恢复以查看)。

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字符在某个地方出现,但粘贴在旧版本中,所以我不知道它在哪里,或者是否相关。

#24


-1  

Just go to the "project setting" and click on the "build phaces" after that you will find targets in that u have to delete the test file like my project name "WER" so its showing like this WER&TEST so just delete that and clean ur project and run .........

进入“项目设置”,点击“构建阶段”之后,你就会发现你需要删除测试文件,比如我的项目名称“WER”,这样它的显示就像这个WER&TEST一样,所以只要删除它,清理你的项目,然后运行它。