Cocoa framework not found

I am new to Swift and just received the book as a present. I’ve been a programmer on mainframe platforms for 30+ years, and currently write applications in Applescript for my company. I’m interested in learning Swift as a replacement for the Applescript applications. That being said, I’m aware of, but not very knowledgeable of Xcode, the GUI programming environment and GUI based apps. So I’m very excited to start working through the book.

I hit my first snag when I tried to create my first Playground. It didn’t show the dialog where I could enter the platform, but created the Playground for IOS. Instead of the import Cocoa statement, it had import UIKit.

Ok, so it targeted for the wrong platform. I closed the playground, created a new one, where I did get the dialog, change to MacOS and now it says import Cocoa. And it can’t find the Cocoa framework, even though it exists in Macintosh HD > System > Libraries > Frameworks > Cocoa.framework > Versions > Current > Cocoa

Where do I look next? This seems like the most basic of problems, but if the standard commands don’t work, it will be tough to debug user created ones :slight_smile:

Hi Jim,

sorry, I am no expert, but maybe delete XCode and try reinstalling it?

Cheers,

Alain

Rolling stone gathers no moss :slight_smile:

Honestly, if I were you, I would not waste precious time with playgrounds. Why not create a simple Xcode project instead and use that as your playground.

Remember, you will be creating your master pieces with Xcode projects not with playgrounds.

If we all stop using playgrounds, Apple will hear the news and divert precious man power to improving developer resources which are in serious disrepair.

Now back to the problem you are experiencing, can you create a Cocoa project in Xcode?

Alain,

Tried reinstall. Still not found. Thanks for the suggestion.

Jim

ibex10,

The reason I’m fooling around with playgrounds is: that’s what’s recommended in the book.

After all, I have the book to teach me how to learn Swift. If the procedures documented in the book don’t work, how can I be sure I’m learning what the authors intended. Besides, I stated that I’m new to GUI programming. Xcode is one of those things that I’m new to, and the first thing I don’t need is to run off in a tangent to learn Xcode just so I can get around the procedures in the book that don’t work. Seems counterproductive.

See the answers in this Stack Overflow post. It helped me solve this exact problem. http://stackoverflow.com/questions/24099364/no-such-module-cocoa-in-swift-playground

Hey, Jim – Hope you were able to get going using the link posted by SkeepDogg. (It’s the second answer, with the rm commands, that did it for me.)

Really sorry this was your intro; hope you stick with it. (I’m pretty much in the same boat as you, having cut my teeth on punched cards, COBOL, FORTRAN, and Assembly.) But this particular experience with Xcode is the exception rather than the rule. If you can stick with it past this initial frustration, you’ll have a good time.