ios 转换为最新语法时出现错误“swiftc 失败,退出代码为 1”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38496582/
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
ERROR "swiftc failed with exit code 1" when converting to latest syntax
提问by ctpanchal
I was trying to convert syntax of old Swift project to new one as per few suggestion on Stack Overflow I tried converting it through Edit > Convert > To latest Syntaxthat did not work properly instead I started getting new errors shown as below
我试图按照 Stack Overflow 上的一些建议将旧 Swift 项目的语法转换为新的语法我尝试通过Edit > Convert > To latest Syntax转换它,但它无法正常工作,而是我开始收到如下所示的新错误
Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
Command/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc 失败,退出代码为 1
And
和
Command /usr/bin/ditto failed with exit code 1
命令 /usr/bin/ditto 失败,退出代码为 1
I tried Xcode 6.0.1 Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1, but it's a different situation.
回答by David
Have you tried to do clean with Clean build folder?
您是否尝试使用Clean build folder进行清理?
The combination keys is:
组合键是:
ALT+ SHIFT+ COMMAND+ K
ALT+ SHIFT+ COMMAND+K
回答by Manuel
Try delete Derived Datafolder and Build it.
尝试删除派生数据文件夹并构建它。
Go to Xcode -> Preferences -> Locations for get the derived data path
转到 Xcode -> Preferences -> Locations 获取派生数据路径
回答by MRizwan33
- Clean Xcode. (cmd+shift+k)
- Quit Xcode completely.
- Open project again.
- Wait for Xcode to indexing files.
- Now run your project.
- 清洁 Xcode。( cmd+ shift+ k)
- 完全退出Xcode。
- 再次打开项目。
- 等待 Xcode 索引文件。
- 现在运行你的项目。
回答by Alaa Awad
Just had the same issue. For me it was because I had renamed some of the project directories. I had a ton of red files in my project navigator. To solve, follow these steps:
刚刚有同样的问题。对我来说,这是因为我重命名了一些项目目录。我的项目导航器中有大量红色文件。要解决,请按照下列步骤操作:
- click on the directory in project navigator where many files show as red
- Under "Identity and Type" in the File Inspector (on the right side), click Containing directory
- Select the new directories
- Rebuild - command shift K, command B
- 单击项目导航器中许多文件显示为红色的目录
- 在文件检查器(右侧)的“身份和类型”下,单击包含目录
- 选择新目录
- 重建 - 命令移位 K,命令 B
回答by Gowtham Sooryaraj
delete Derived Data folder and Build it.
删除派生数据文件夹并构建它。
Go to Xcode -> Preferences -> Locations for get the derived data path or cmd+Alt+shift+k
转到 Xcode -> Preferences -> Locations 获取派生数据路径或 cmd+Alt+shift+k
OR
或者
Just remove inactive file(deleted file) from Build phases
只需从构建阶段中删除非活动文件(已删除文件)
回答by Sanket Ray
As far as I know there can be multiple reasons why a compiler fails. Although cmd+alt+shift+kwill help most of the time. If this fails, then click on the error message and try to debug it.
据我所知,编译器失败可能有多种原因。尽管cmd+ alt+ shift+k将帮助大部分时间。如果失败,则单击错误消息并尝试对其进行调试。
For example in the image below, if you read the message, we get to know that, there has been a name duplication. Fixing the name duplication will fix the issue.
例如在下图中,如果您阅读消息,我们就会知道,存在名称重复。修复名称重复将解决该问题。
回答by Rabie
Just remove inactive file(deleted file) from Build phases
只需从构建阶段中删除非活动文件(已删除文件)
then
然后
Clean Xcode. (cmd+shift+k)
清洁 Xcode。( cmd+ shift+ k)
回答by ivoroto
Cleaning the project wasn't working for me, this is because I didn't pay attention to the message right above (Xcode highlights only the final command).
清理项目对我不起作用,这是因为我没有注意上面的消息(Xcode 仅突出显示最终命令)。
In my case it was
就我而言,它是
<unknown>:0: error: filename "FileDuplicated.swift" used twice: '/../filepath/FileDuplicated.swift' and '/../filepath/FileDuplicated.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /../bin/swiftc failed with exit code 1
I had to change the name of one of the two files and it was solved.
我不得不更改两个文件之一的名称并解决了。
Hope this can help someone, cheers
希望这可以帮助某人,干杯
回答by Vishnuvardhan
In my case it was due to the few swift files which has been showed grayed out in the Build Phases section. After removing those files it was successful.
就我而言,这是由于在“构建阶段”部分中显示为灰色的少数 swift 文件。删除这些文件后,它成功了。
回答by xdeleon
Ok, my turn now. In my case I had an existing project. I copied in a few files from another project. One of the files I brought in was SettingsViewController.swift and there was already a file by the same name I was not aware of. The files were in different directories of the project so no duplicate message was shown. The compile/link messages offered no clue to this. I figured out the issue by adding one file at a time to the project (there were 12 total) and the building each time until I found the offending file. I renamed the new file and project builds now.
好的,现在轮到我了。就我而言,我有一个现有的项目。我从另一个项目中复制了几个文件。我带来的文件之一是 SettingsViewController.swift 并且已经有一个我不知道的同名文件。这些文件位于项目的不同目录中,因此没有显示重复的消息。编译/链接消息对此没有提供任何线索。我通过一次向项目(总共有 12 个)和建筑物添加一个文件来解决这个问题,直到我找到有问题的文件。我现在重命名了新文件和项目构建。