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. This is an OSX project, not iOS and the problem happens on all projects, including newly created ones.
I've verified and repaired disk permissions, checked the disk for errors, and reset Xcode to default settings.
To use SwiftyJSON, you have to download the correct version from the Git repository. Simply, drag the "SwiftyJSON. swift" into your project and import into your class: import SwiftyJSON.
I had this problem today in a Swift test-case class. 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.
Which is to say that instead of import Cocoa
at the top of my test-case file, I should have had import UIKit
.
Figured it was worth leaving this as an answer to save people uninstalling and reinstalling Xcode without necessarily needing to.
I encountered the same problem and reinstalled the Xcode,the problem still there.
Finally I found my Xcode logs SourceKitService crashed error,and found the answer on 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
defaults delete com.apple.dt.Xcode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With