简体   繁体   English

Xcode 6.1:在所有OSX Swift项目中突然没有这样的模块'cocoa'

[英]Xcode 6.1: no such module 'cocoa' suddenly in all OSX Swift projects

I have been using Xcode 6.1 without issue for several days but suddenly I'm getting the error no such module 'Cocoa' in all of my Swift files. 几天来我一直在使用Xcode 6.1没有问题,但突然间我在所有Swift文件中都收到错误没有这样的模块'Cocoa' This is an OSX project, not iOS and the problem happens on all projects, including newly created ones. 这是一个OSX项目,而不是iOS,所有项目都会出现问题,包括新创建的项目。

I've verified and repaired disk permissions, checked the disk for errors, and reset Xcode to default settings. 我已经验证并修复了磁盘权限,检查了磁盘是否有错误,并将Xcode重置为默认设置。

I had this problem today in a Swift test-case class. 我今天在Swift测试用例类中遇到了这个问题。 I tried both of the suggested answers, but it didn't fix the issue. 我尝试了两个建议的答案,但它没有解决问题。 It turned out to be user-error - I had accidentally created an OS X test-case class in an iOS application. 结果是用户错误 - 我不小心在iOS应用程序中创建了一个OS X测试用例类。

Which is to say that instead of import Cocoa at the top of my test-case file, I should have had import UIKit . 也就是说,我不应该在我的测试用例文件的顶部import Cocoa ,而应该import UIKit

Figured it was worth leaving this as an answer to save people uninstalling and reinstalling Xcode without necessarily needing to. 认为值得留下这个作为一个答案,以节省人们卸载和重新安装Xcode,而无需。

I encountered the same problem and reinstalled the Xcode,the problem still there. 我遇到了同样的问题并重新安装了Xcode,问题仍然存在。

Finally I found my Xcode logs SourceKitService crashed error,and found the answer on twitter 最后我发现我的Xcode记录SourceKitService崩溃错误,并在twitter上找到答案

open terminal and execute: 打开终端并执行:

rm -rf ~/Library/Developer/Xcode/DerivedData

It's works for me! 它对我有用!

or you can reset Xcode defaults by command line 或者您可以通过命令行重置Xcode默认值

defaults delete com.apple.dt.Xcode

Deleting and reinstalling Xcode solved the issue. 删除并重新安装Xcode解决了这个问题。 Thank you radex for the suggestion. 谢谢radex的建议。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM