Xcode 6 Beta: no such Cocoa module

I am trying to use the Cocoa standard library in a fast file in Xcode 6 Beta. I followed these instructions , but when I import the library

import Cocoa 

Xcode complains about error

 No such module 'Cocoa' 

I also tried with REPL and I have no problems at all. I suppose this is a mistake because I started different projects, and only sometimes I get this error. Any suggestions? I am using Mavericks (10.9.3)

+43
xcode swift
Jun 08 '14 at 20:29
source share
7 answers

You cannot import Cocoa from an iOS playground or application. Make sure your code is running on the Cocoa Playground (choose OS X> Source in the new file dialog).

+39
Jun 08 '14 at 20:32
source share

Replace

 import Cocoa 

FROM

 import UIKit 
+120
02 Sep '14 at 19:37
source share

From your question, it seems that you are trying to add the Cocoa class to your iOS application instead of the Cocoa Touch class . So this is not an Xcode error.

Be sure to select the template located in the iOS section shown in the following screenshot, as we select it for the iOS application.

enter image description here

+21
Dec 24 '15 at 13:09 on
source share

If you have already created your playground, you can switch between iOS and OS X platforms in the "File Inspector" dialog box; no need to create a new playground. import Cocoa will only work for the OS X playground.

Go to "View"> "Utilities"> "Show File Inspector", and then "on the right" in the "Playground Settings" section

+8
Jun 08 '14 at 21:19
source share

you need to get xcode 6.1 (beta) to use Swift with OS X

+2
Oct 06 '14 at 9:41
source share

You can open the Utilities tab (top right) and simply switch the platform from the "Playground Settings" section. If you switch it from iOS to OS X, the problem will be resolved.

+1
Jun 20 '16 at 15:47
source share

Structure named Cocoa does not exist

Remove

import Cocoa

and everything should work from scratch.

If this does not work for any reason, you can import Foundation or UIKit frameworks.

0
Jun 08 '14 at 20:44
source share



All Articles