import Swift vs import Foundation

Yes, you will only need import Foundation if you want to access NSObject or one of its subclasses. Foundation is the framework that brings in that class hierarchy. However, it’s highly likely that in a project you’ll need more than just import Swift. Like Rob commented, import UIKit is also a nice option.

In case you haven’t read it already, Apple explains the Foundation framework here.

Leave a Comment

tech