Justin Sheckler - Porting Objective-C to Swift

Justin Sheckler - Porting Objective-C to Swift

Justin Sheckler presenting at the July 2014 Brooklyn Swift Developers Meetup: http://meetup.com/Brooklyn-Swift-Developers/events/194378492/

Video: https://vimeo.com/102163541
Code: http://bit.ly/objc2swiftdemo

Transcript

  1. Porting Obj-C to Swift Justin Sheckler, Etsy

  2. Should I port my code?

  3. Maybe!

  4. You’re still using Obj-C (for now, at least)

  5. Read the Docs! http://bit.ly/objc2swift

  6. Adding Swift to an Existing Project

  7. Just add a new file and go

  8. Your New Best Friend: The Bridging Header It imports Swift

    classes into Obj-C.
  9. Point to custom Bridging Header in Build Settings

  10. Where do I Start?

  11. But, Can I Import Swift Back Into Obj-C? Yes! But

    it works totally differently. ಠ_ಠ
  12. The Compatibility Header Your new second-best friend.

  13. Let’s Demo! http://bit.ly/objc2swiftdemo

  14. Gotchas! • Be careful of custom Obj-C types in Swift

    arguments • May need to cast primitive types to/from plain-C APIs • Obj-C/Swift bridges may still be buggy
  15. Questions? @jayKayEss http://bit.ly/objc2swift (Apple docs) http://bit.ly/objc2swiftdemo (My Demo)