

All I need to do is open the Related Items menu in the top left of the editor. But if I import it into Swift, the compiler will automatically translate it into a Swift API, and I can see what that API will look like right in Xcode by looking at the header's generated interface. If I look at the headers, it's clear that this is an Objective-C framework full of #import directives, blocks, methods with selectors. So it can describe, you know, astronauts, missions, rockets and so on. SpaceKit is an Objective-C framework which has a few model APIs for describing NASA's early, crude space program. I'm going to teach you the techniques that Apple's Objective-C frameworks use to improve how they're imported into Swift.Īnd to do that, I'll be using a little framework I call SpaceKit. We designed in ways to customize the translation by adding macros and keywords to your header files.Īnd we built in the ability to extend Objective-C frameworks with custom Swift code to wrap existing APIs or add new ones that can't be expressed in Objective-C.īest of all, we designed all of this to work not just for us, but for you. So, we designed Swift to not only import our Objective-C frameworks, but also to automatically translate them into more idiomatic Swift APIs. We probably have more Objective-C frameworks than anyone in the world. We understand that because Apple is in the same boat. So, many of you still have a lot of Objective-C code today that's increasingly being used by Swift clients.


But Apple's platforms spent a very long time as Objective-C-only platforms, and a lot of you couldn't adopt Swift right away. Most of you have turned into Swift developers. Since then, something amazing has happened. We first introduced Swift six years ago this month.
#Sononym for swift how to
I'm gonna talk to you today about how to make your Objective-C frameworks work really nicely in Swift.
