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.
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.
-
Oh my gosh this is amazing. Is there anyway to access this through other means (like the way you could navigate to the objc header files in the file browser)? And I guess my main question is, where can I learn more about Swift modules? I've been searching the documentation and reading the iBook but it's still a mystery. – Halen May 12 '15 at 3:47
-
Swift documentation from Apple is pretty sparse right now. What you can find by command-clicking things in Xcode is pretty much all there is. – rob mayoff May 12 '15 at 15:39