Xcode 7 失败,命令 /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/32647659/
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-09-15 07:50:52  来源:igfitidea点击:

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

iosxcodeswiftcocoapods

提问by Luis Delgado

I am going through the process of updating my swift project to Swift 2.0 on Xcode 7. The following error is being reported by xcode on building the project:

我正在 Xcode 7 上将我的 swift 项目更新到 Swift 2.0。xcode 在构建项目时报告了以下错误:

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 failed with exit code 1

This happens on either SwiftyJSON or SwiftSpinner frameworks (the compiler seems to pick one first at random and fail, so the error gets reported intermittently on either or the other). I have updated these frameworks to their xcode7/swift2 compatible branches but the project still fails to compile.

这发生在 SwiftyJSON 或 SwiftSpinner 框架上(编译器似乎随机选择第一个并失败,因此错误会在其中一个或另一个上间歇性地报告)。我已将这些框架更新到与 xcode7/swift2 兼容的分支,但该项目仍然无法编译。

Just wondering if this is a situation other people are seeing when upgrading their project with cocoa pods framework dependencies, or if this is a compiler bug

只是想知道这是其他人在使用可可豆荚框架依赖项升级他们的项目时看到的情况,还是编译器错误

回答by Morten Holmgaard

For others with a similar problem try this: Open Console (not terminal) and choose All Messages. Then try to build your Xcode project and when it fails take a look in the list there with any message that could be related to Xcode.

对于其他有类似问题的人,试试这个:打开控制台(不是终端)并选择所有消息。然后尝试构建您的 Xcode 项目,当它失败时,请查看列表中可能与 Xcode 相关的任何消息。

I found a message like this:

我发现了一条这样的消息:

01/10/15 10.24.17,808 Xcode[53145]: DVTAssertions: Warning in /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-8228/IDEFoundation/Playgrounds/IDEPlaygroundAuxiliarySourceCompilerOperation.m:311 Details: Unable to read diagnostics from file "/Users/username/Library/Developer/Xcode/DerivedData/OurProject-diexylwajzhwgtfqdwiphjgzdwcy/Build/Intermediates/OurProject.build/Debug-iphoneos/OurProject.build/Objects-normal/armv7/CheckoutUserDataAdapter.dia" (Invalid File): Invalid diagnostics signature Function: void XCGenerateDiagnosticsFromFile(NSString *__strong, NSString *__strong, NSDictionary *__strong, NSDictionary *__strong, IDEActivityLogSectionRecorder *__strong, BOOL (^__strong)(IDEActivityLogMessage *__strong)) Thread: {number = 250, name = (null)} Please file a bug at http://bugreport.apple.comwith this warning message and any useful information you can provide.

01/10/15 10.24.17,808 Xcode[53145]:DVTAssertions:警告在 /Library/Caches/com.apple.xbs/Sources/IDEFrameworks/IDEFrameworks-8228/IDEFoundation/Playgrounds/IDEPlaygroundAuxiliarySource3Compiler1Operation.m 中的警告:Unified来自文件“/Users/username/Library/Developer/Xcode/DerivedData/OurProject-diexylwajzhwgtfqdwiphjgzdwcy/Build/Intermediates/OurProject.build/Debug-iphoneos/OurProject.build/Objects-normal/armv7/CheckoutUserDataAdapter.dia”的诊断(无效文件): 无效的诊断签名函数: void XCGenerateDiagnosticsFromFile(NSString *__strong, NSString *__strong, NSDictionary *__strong, NSDictionary *__strong, IDEActivityLogSectionRecorder *__strong, BOOL (^__strong)(IDEActivityLogMessage *__strong)) 线程: {number = 250, name = (null)} 请在以下位置提交错误 http://bugreport.apple.com包含此警告消息以及您可以提供的任何有用信息。

This gave us info that the error was in CheckoutUserDataAdapter.swift. After trial and error we found that the problem was it was calling a method from its super class that it overrides from its super class. Somehow it could not find the correct method.
We fixed it by adding super.methodCall() in CheckoutUserDataAdapter.swift - but that of cause should not be needed. I have filed a bug report.

这告诉我们错误出在 CheckoutUserDataAdapter.swift 中。经过反复试验,我们发现问题在于它从它的超类调用一个方法,它从它的超类覆盖。不知何故,它找不到正确的方法。
我们通过在 CheckoutUserDataAdapter.swift 中添加 super.methodCall() 来修复它 - 但不应该需要原因。我已经提交了错误报告。

回答by Dug

Check Build Phases - Compile Sources for deleted files, or files with a blank icon, once this file was removed the error was gone

检查构建阶段 - 为已删除的文件或带有空白图标的文件编译源,一旦删除此文件,错误就消失了

回答by rockiesGrizzly

Thanks @Dug for the Build Phase tip. I ended up going a different direction than the deletion...

感谢 @Dug 提供构建阶段提示。我最终走向了与删除不同的方向......

After checking Build Phases - Compile Sources, find the files that are grayed out (don't currently have a link to an actual file) to identify the files in question.

检查 Build Phases - Compile Sources 后,找到灰显的文件(当前没有指向实际文件的链接)以识别有问题的文件。

If the files are still being used, then find them in the Project Navigator (left hand column) and you'll see that they're colored red because Xcode only has a reference and not a location for the actual file.

如果这些文件仍在使用中,那么在 Project Navigator(左栏)中找到它们,您会看到它们是红色的,因为 Xcode 只有一个引用而不是实际文件的位置。

Select each red file and then head to the File Inspector (right hand column). You'll see "Location". Locate your files by clicking the gray folder and finding them in the file structure outside of Xcode.

选择每个红色文件,然后前往文件检查器(右侧列)。您会看到“位置”。通过单击灰色文件夹并在 Xcode 之外的文件结构中找到它们来定位您的文件。

If you're working with a repo, you may find it easier to simply remove the red files, choose File > Add Files to... and simply re-add them so the link is more generic rather than pointing directly to your machine's file location.

如果您正在使用存储库,您可能会发现简单地删除红色文件更容易,选择“文件”>“将文件添加到...”,然后简单地重新添加它们,这样链接就更通用,而不是直接指向您机器的文件地点。

This happened to me after a project file merge in which I'd been branched from the main repo for quite a while so a handful of file locations were lost in the merge.

这发生在我在项目文件合并之后发生的,其中我从主存储库分支了很长一段时间,因此在合并中丢失了一些文件位置。