"no such module cocoa" error occurs in Swift

In Swift development, a new subclass of UITableViewCell is created: CustomerUITableViewCell, and the error "No such module 'Cocoa' appears:

The reason is simple: when creating a new File file, the "OS X" project was selected, but the "iOS" project should actually be selected. So delete the wrong file and re-create a new File file, the problem is solved:

it turned out that I ignored this point, which caused the problem.

Note: OS X playground (Cocoa-based) is based on Cocoa, while iOS playground (UIKit-based) is based on UIKit;

At the same time, you can also directly modify the code of an existing swift (or playground) file.

import UIKit

directly modified to

import Cocoa
can

Guess you like

Origin blog.csdn.net/enuola/article/details/41978539