Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What gets imported with UIKit, and how do I find out?

When using Objective-C and importing headers, it made sense to me what was getting imported. For example, I only have to import UIKit but I can use CoreGraphics, for example. How can I tell what other frameworks each framework is importing with Swift? All I'm doing is importing UIKit, but I can still use Core Graphics. I've searched the documentation, but the framework reference doesn't mention it.

like image 398
Halen Avatar asked May 12 '15 02:05

Halen


1 Answers

Open your Swift source file. Find the import UIKit line. Command-click on the word UIKit. You'll see what UIKit imports:

import Foundation
import UIKit.NSAttributedString
import UIKit.NSFileProviderExtension
import UIKit.NSLayoutConstraint
import UIKit.NSLayoutManager
import UIKit.NSParagraphStyle
import UIKit.NSShadow
import UIKit.NSStringDrawing
import UIKit.NSText
import UIKit.NSTextAttachment
import UIKit.NSTextContainer
... many more

Command-click on the word Foundation on the first line to see what it imports:

import CoreFoundation
import CoreGraphics
import Foundation.FoundationErrors
import Foundation.NSArray
import Foundation.NSAttributedString
import Foundation.NSAutoreleasePool
import Foundation.NSBundle
import Foundation.NSByteCountFormatter
import Foundation.NSByteOrder
... many more

Repeat until bored or satisfied.

like image 63
rob mayoff Avatar answered Oct 08 '22 12:10

rob mayoff