Xcode 7在命令/应用/Xcode.app/内容/开发人员/工具链/XcodeDefault时失败。xctoolchain/usr/bin/swiftc以退出代码1失败。

时间:2023-01-22 23:40:49

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:

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

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

命令/应用程序/ xcode /内容/开发/工具链/ XcodeDefault。xctoolchain/usr/bin/swiftc以退出代码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

只是想知道这是否是其他人在用cocoa pods框架依赖项升级他们的项目时看到的情况,或者这是一个编译器错误

3 个解决方案

#1


9  

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.com with this warning message and any useful information you can provide.

01/10/15 10.24.17,808 Xcode[53145]: dvt断言:在/Library/ cache /com.apple.xbs/ source / ideframeworks8228 / ideframeworks8228 / ideframeworks8228 / ideframeworks8228 / ideframeworks8228 / ideframeworks-m:311详细信息:无法从文件“/用户/用户名/库/开发人员/Xcode/派生数据/项目-diexylwajzhwgtfqdwiphjgzdwcy/Build/ medium /OurProject.build/Debug-iphoneos/OurProject.build/Objects-normal/armv7/CheckoutUserDataAdapter。dia”(无效的文件):无效的诊断签名功能:空白XCGenerateDiagnosticsFromFile(NSString *强烈,NSString *强烈,NSDictionary *强烈,NSDictionary *强烈,IDEActivityLogSectionRecorder *强烈,BOOL(^强烈)(IDEActivityLogMessage *强烈))线程:{数量= 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中添加super.methodCall()来修复它。迅速——但这是不需要的。我已经提交了一份错误报告。

#2


4  

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

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

#3


2  

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.

在检查构建阶段——编译源代码之后,找到灰色的文件(目前没有实际文件的链接),以识别有问题的文件。

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.

如果您正在使用repo,您可能会发现简单地删除红色文件更容易,选择File >添加文件到……并且只需重新添加它们,以便链接更通用,而不是直接指向计算机的文件位置。

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.

我在一个项目文件合并之后发生了这样的事情,我从主要的repo中分支了相当长的一段时间,所以在合并中丢失了一些文件位置。

#1


9  

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.com with this warning message and any useful information you can provide.

01/10/15 10.24.17,808 Xcode[53145]: dvt断言:在/Library/ cache /com.apple.xbs/ source / ideframeworks8228 / ideframeworks8228 / ideframeworks8228 / ideframeworks8228 / ideframeworks8228 / ideframeworks-m:311详细信息:无法从文件“/用户/用户名/库/开发人员/Xcode/派生数据/项目-diexylwajzhwgtfqdwiphjgzdwcy/Build/ medium /OurProject.build/Debug-iphoneos/OurProject.build/Objects-normal/armv7/CheckoutUserDataAdapter。dia”(无效的文件):无效的诊断签名功能:空白XCGenerateDiagnosticsFromFile(NSString *强烈,NSString *强烈,NSDictionary *强烈,NSDictionary *强烈,IDEActivityLogSectionRecorder *强烈,BOOL(^强烈)(IDEActivityLogMessage *强烈))线程:{数量= 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中添加super.methodCall()来修复它。迅速——但这是不需要的。我已经提交了一份错误报告。

#2


4  

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

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

#3


2  

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.

在检查构建阶段——编译源代码之后,找到灰色的文件(目前没有实际文件的链接),以识别有问题的文件。

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.

如果您正在使用repo,您可能会发现简单地删除红色文件更容易,选择File >添加文件到……并且只需重新添加它们,以便链接更通用,而不是直接指向计算机的文件位置。

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.

我在一个项目文件合并之后发生了这样的事情,我从主要的repo中分支了相当长的一段时间,所以在合并中丢失了一些文件位置。