bringing swift into your objective-c projects
TRANSCRIPT
![Page 1: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/1.jpg)
Bringing Swift into your
Objective-C Projects
![Page 2: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/2.jpg)
Before we go any further…
![Page 3: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/3.jpg)
Hold the tomatoes, I don’t hate Objective-C
![Page 4: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/4.jpg)
Why does this matter?
![Page 5: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/5.jpg)
Apple is all in
![Page 6: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/6.jpg)
Learning Curve
![Page 7: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/7.jpg)
Better Apps
![Page 8: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/8.jpg)
Not going to discuss
• Swift Syntax
• Value vs Reference types
• How to convince your team
![Page 9: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/9.jpg)
Sit Back &
Relax
![Page 10: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/10.jpg)
Let’s Dive In
![Page 11: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/11.jpg)
The Journey
![Page 12: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/12.jpg)
Rewind to June 2014
![Page 13: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/13.jpg)
Still Learning iOS 7
![Page 14: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/14.jpg)
it’s that time of the year
![Page 15: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/15.jpg)
![Page 16: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/16.jpg)
no golden ticket
![Page 17: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/17.jpg)
I was all ears
![Page 18: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/18.jpg)
drinking mimosas with friends, watching
![Page 19: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/19.jpg)
![Page 20: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/20.jpg)
and then, all of the sudden
![Page 21: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/21.jpg)
Hair Force One gets on stage and…
![Page 22: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/22.jpg)
![Page 23: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/23.jpg)
![Page 24: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/24.jpg)
![Page 25: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/25.jpg)
And so the journey began…
![Page 26: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/26.jpg)
started studying & practicing,
![Page 27: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/27.jpg)
used Swift for anything I could think of,
![Page 28: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/28.jpg)
wrote some tutorials,
![Page 29: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/29.jpg)
taught classes at work,
![Page 30: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/30.jpg)
and tech reviewed a couple of books.
![Page 31: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/31.jpg)
I was ready
![Page 32: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/32.jpg)
Two Big Ideas
![Page 33: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/33.jpg)
Two Big Ideas
1. Learn by Doing, but not doing too much
2. Maximize Benefits
![Page 34: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/34.jpg)
Learn by Doing, but not doing too much
Big Idea 1
![Page 35: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/35.jpg)
{1} Jump
{2} One View Controller
{3} Everything above view controller
Learn
![Page 36: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/36.jpg)
{1} Jump
{2} One View Controller
{3} Everything above view controller
{1} Jump
{2} One View Controller
{3} Everything above view controller
Learn
![Page 37: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/37.jpg)
{1} Jump
![Page 38: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/38.jpg)
Back at work…
![Page 39: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/39.jpg)
inherited Objective-C project
![Page 40: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/40.jpg)
and we thought, should we start using Swift?
![Page 41: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/41.jpg)
Fellowship Formed
![Page 42: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/42.jpg)
took the plunge
![Page 43: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/43.jpg)
Why on Earth would I want to start writing Swift
when I have deadlines?
![Page 44: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/44.jpg)
Why Swift
• Faster & More Stable Apps
• Less Typing, I’m More Efficient
• It’s the future
![Page 45: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/45.jpg)
So where to start?(Architecturally)
![Page 46: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/46.jpg)
User Interface
UIApplication
UIApplicationDelegate
Core Logic
Persistence Networking Other Utilities
UIView
UIViewControllerUIViewController
UIView
UIWindow
UIViewController
UIView
![Page 47: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/47.jpg)
Started at the top…
now we’re here
![Page 48: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/48.jpg)
{1} Jump
{2} One View Controller
{3} Everything above view controller
{1} Jump
{2} One View Controller
{3} Everything above view controller
Learn
![Page 49: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/49.jpg)
{2} One View Controller
![Page 50: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/50.jpg)
when we talk view controller it includes
the root view
![Page 51: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/51.jpg)
Swift
Objective-C
![Page 52: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/52.jpg)
User Interface
UIApplication
UIApplicationDelegate
Core Logic
Persistence Networking Other Utilities
UIView
UIViewControllerUIViewController
UIView
UIWindow
UIViewController
UIView
![Page 53: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/53.jpg)
User Interface
UIApplication
UIApplicationDelegate
Core Logic
Persistence Networking Other Utilities
UIView
UIViewControllerUIViewControllerUIViewController
UIView UIView
UIWindow
UIViewController
UIView
![Page 54: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/54.jpg)
Why did we start here?
![Page 55: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/55.jpg)
Why did we start here?
• Minimize Risk
• Nice Set-up
• It’s Clean
![Page 56: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/56.jpg)
Minimize Risk
![Page 57: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/57.jpg)
Minimize Risk
• Don’t have to learn the whole language
• Easy U-turn
• Small and contained
![Page 58: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/58.jpg)
Nice Set-up
![Page 59: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/59.jpg)
Nice Set-up
• Flow Swift safety up into view controllers
• Setup for actually improving app
• Critical for re-writes
![Page 60: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/60.jpg)
It’s Clean
![Page 61: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/61.jpg)
It’s Clean
• One single file
• Easy to coordinate within team
• Don’t have to worry about things ObjC can’t see
![Page 62: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/62.jpg)
Ok, so started building my first Swifty view controller
![Page 63: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/63.jpg)
first step…
![Page 64: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/64.jpg)
![Page 65: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/65.jpg)
![Page 66: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/66.jpg)
![Page 67: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/67.jpg)
![Page 68: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/68.jpg)
you’ll need to import Objective-C headers in
the bridging header
![Page 69: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/69.jpg)
got my .swift view controller ready to build
![Page 70: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/70.jpg)
time to build
![Page 71: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/71.jpg)
started writing some autolayout code
using Masonry, and…
![Page 72: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/72.jpg)
Misty Mountains
![Page 73: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/73.jpg)
Swift does not support macros
![Page 74: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/74.jpg)
Masonry uses macros
![Page 75: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/75.jpg)
but…
![Page 76: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/76.jpg)
there’s a Swift version!
![Page 77: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/77.jpg)
let me just go update my podfile…
![Page 78: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/78.jpg)
Mines of Moria
![Page 79: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/79.jpg)
cannot package Swift in static libraries
![Page 80: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/80.jpg)
wait what? really!?
![Page 81: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/81.jpg)
doesn’t CocoaPods output static libraries?
![Page 82: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/82.jpg)
bingo.
![Page 83: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/83.jpg)
use_frameworks!{if targeting iOS 8 and above}
![Page 84: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/84.jpg)
Encountered Balrog
![Page 85: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/85.jpg)
Parse SDK pod didn’t like living in a framework
![Page 86: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/86.jpg)
… domino effect
![Page 87: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/87.jpg)
So watch out, you will hit a snag…
![Page 88: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/88.jpg)
good news is,
![Page 89: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/89.jpg)
Parse SDK now works with use_frameworks!
![Page 90: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/90.jpg)
Ok, back to building the view controller
![Page 91: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/91.jpg)
looks like I need some logging…
![Page 92: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/92.jpg)
no problem, CocoaLumberjack’s
already in my podfile :]
![Page 93: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/93.jpg)
Mordor's Black Gate
![Page 94: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/94.jpg)
remember, Swift does not
support macros
![Page 95: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/95.jpg)
it’s ok because…
![Page 96: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/96.jpg)
CocoaLumberjack version 2.0.0
doesn’t macro
![Page 97: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/97.jpg)
there’s a migration guide on GitHub
![Page 98: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/98.jpg)
and don’t forget to run all your schemes
![Page 99: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/99.jpg)
build and run…
![Page 100: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/100.jpg)
Shelob
![Page 101: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/101.jpg)
Tweaks
ALSO based on macros…
![Page 102: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/102.jpg)
Just need to replace macros with Swift code
![Page 103: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/103.jpg)
Check out ‘Using from a Swift Project’ section in
Tweaks README on GitHub
![Page 104: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/104.jpg)
Things we ran into
• Lumberjack
• Masonry/SnapKit
• Cocoapods / Parse
• Tweaks
![Page 105: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/105.jpg)
don’t let this scare you
![Page 106: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/106.jpg)
Swift is being adopted at an incredible pace
![Page 107: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/107.jpg)
Ok, view controller complete…
![Page 108: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/108.jpg)
time to plug it in
![Page 109: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/109.jpg)
in code or
Interface Builder
![Page 110: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/110.jpg)
In code
in container view controller #import {module}-Swift.h
![Page 111: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/111.jpg)
Interface Builder
do nothing! (special)
![Page 112: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/112.jpg)
{1} Jump
{2} One View Controller
{3} Everything above view controller
{1} Jump
{2} One View Controller
{3} Everything above view controller
Learn
![Page 113: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/113.jpg)
{3} Everything Above
View Controller
![Page 114: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/114.jpg)
moved on up to root view controller
![Page 115: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/115.jpg)
Core Logic
User Interface
UIApplication
UIApplicationDelegate UIWindow
Persistence Networking Other Utilities
UIView
UIViewControllerUIViewControllerUIViewController
UIViewController
UIView UIView
UIView
![Page 116: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/116.jpg)
Core Logic
User Interface
UIApplication
UIApplicationDelegate UIWindow
Persistence Networking Other Utilities
UIView
UIViewControllerUIViewControllerUIViewController
UIViewController
UIView UIView
UIView
![Page 117: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/117.jpg)
and up again…
![Page 118: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/118.jpg)
Core Logic
User Interface
UIApplication
UIApplicationDelegate UIWindow
Persistence Networking Other Utilities
UIView
UIViewControllerUIViewControllerUIViewController
UIViewController
UIView UIView
UIView
![Page 119: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/119.jpg)
Core Logic
User Interface
UIApplication
UIApplicationDelegate UIWindow
Persistence Networking Other Utilities
UIView
UIViewControllerUIViewControllerUIViewController
UIViewController
UIView UIView
UIView
![Page 120: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/120.jpg)
So far
![Page 121: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/121.jpg)
So far
• We implemented a new view controller in Swift
• We re-implemented root view controller in Swift
• We re-implemented app delegate in Swift
![Page 122: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/122.jpg)
We got a taste of Swift
![Page 123: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/123.jpg)
{1} Jump
{2} One View Controller
{3} Everything above view controller
{1} Jump
{2} One View Controller
{3} Everything above view controller
Learn
![Page 124: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/124.jpg)
this next step is crucial
![Page 125: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/125.jpg)
Maximize BenefitsBig Idea 2
![Page 126: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/126.jpg)
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
Maximize Benefits
![Page 127: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/127.jpg)
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
Maximize Benefits
![Page 128: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/128.jpg)
{1} Think Vertical
Probably the most important topic of this talk.
![Page 129: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/129.jpg)
it’s tempting to continue building view controllers
![Page 130: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/130.jpg)
it’s also tempting to move on to core logic
![Page 131: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/131.jpg)
but first,
![Page 132: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/132.jpg)
let’s understand how Swift can help
make your apps better
![Page 133: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/133.jpg)
better means material improvement
![Page 134: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/134.jpg)
actually improving your app
![Page 135: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/135.jpg)
if Swift can’t have a material impact on
your product…
![Page 136: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/136.jpg)
then WHO CARES!
![Page 137: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/137.jpg)
but Swift can!
![Page 138: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/138.jpg)
How?
![Page 139: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/139.jpg)
Safety & Speed
![Page 140: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/140.jpg)
Let’s focus on safety
![Page 141: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/141.jpg)
Safety means less chance of crashing
![Page 142: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/142.jpg)
How
![Page 143: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/143.jpg)
How
• Static typing
• Enforcing nullability & non nullability
• Immutability & value semantics
![Page 144: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/144.jpg)
These are Swift only features
![Page 145: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/145.jpg)
Objective-C code that calls Swift code does not benefit
![Page 146: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/146.jpg)
So we want to use Swift types across as many
sub-systems as we can
![Page 147: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/147.jpg)
this means across UI - Core Logic boundary
![Page 148: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/148.jpg)
so how did we use this to our advantage?
![Page 149: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/149.jpg)
we went vertical
![Page 150: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/150.jpg)
we identified vertical slices
![Page 151: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/151.jpg)
what’s a vertical slice?
![Page 152: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/152.jpg)
Core Logic
User Interface
UIApplication
UIApplicationDelegate UIWindow
Persistence Networking Other Utilities
UIView
UIViewControllerUIViewController
UIViewController
UIView
UIView
![Page 153: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/153.jpg)
UIApplication
UIApplicationDelegate
Persistence
Networking
Other Utilities
UIViewController UIView
VC VC
V V
Vertical Slice
![Page 154: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/154.jpg)
we then re-factored our view controller to communicate with
core logic using Swift types
![Page 155: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/155.jpg)
UIApplication
UIApplicationDelegate
Persistence
Networking
Other Utilities
UIViewController UIView
VC
V
VC
V
P
N
O
![Page 156: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/156.jpg)
pure Swift core logic, only for pure Swift
view controllers
![Page 157: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/157.jpg)
Key Insight use Swift types across
the entire stack
![Page 158: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/158.jpg)
remember, we are trying to maximize
our use of Swift
![Page 159: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/159.jpg)
ok so that’s what we did, you might be
wondering…
![Page 160: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/160.jpg)
why not start at the bottom?
![Page 161: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/161.jpg)
why not just build the core logic in Swift?
![Page 162: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/162.jpg)
UIApplication
UIApplicationDelegate
Persistence
Networking
Other Utilities
UIViewController UIView
VC VC
V V
VC
V
VC
V
VC
V
![Page 163: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/163.jpg)
I hear this a lot
![Page 164: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/164.jpg)
so quick sidebar, here’s the argument
![Page 165: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/165.jpg)
{this goes for codebases that will be worked on for
the foreseeable future}
![Page 166: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/166.jpg)
let’s say we decide to do this
![Page 167: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/167.jpg)
if we go horizontal…
![Page 168: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/168.jpg)
we won’t maximize our use of Swift
![Page 169: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/169.jpg)
and we’ll paint ourselves into a corner
![Page 170: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/170.jpg)
why?
![Page 171: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/171.jpg)
if we start at the bottom, we’ll definitely have Objective-C
consuming our Swift code
![Page 172: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/172.jpg)
Why is that bad?
![Page 173: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/173.jpg)
we’ll end up designing for least common
denominator
![Page 174: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/174.jpg)
Objective-C View Controller
Objective-C View Controller
Objective-C View Controller Objective-C View Controller
Core Logic Objective-CSuperclass
Swift Core Logic
Core Logic Objective-CSuperclass
Swift Core Logic
Core Logic Objective-CSuperclass
Swift Core Logic
![Page 175: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/175.jpg)
we’ll want Objective-C and Swift view controllers
to use our Swift base
![Page 176: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/176.jpg)
Objective-C View Controller
Swift View Controller
Objective-C View Controller
Objective-C View Controller Objective-C View Controller
Core Logic Objective-CSuperclass
Swift Core Logic
Core Logic Objective-CSuperclass
Swift Core Logic
Core Logic Objective-CSuperclass
Swift Core Logic
![Page 177: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/177.jpg)
we’ll end up building non Swifty interfaces
between UI and core logic
![Page 178: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/178.jpg)
this will leak deep into both UI and core logic
![Page 179: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/179.jpg)
Objective-C Superclass
Swift Subclass
Objective-C ObjectObjective-C Object
Objective-C Object
Objective-C Object
Swift Class Object
Swift Class Object
![Page 180: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/180.jpg)
Objective-C Superclass
Swift Subclass
Objective-C ObjectObjective-C Object
Objective-C Object
Objective-C Object
Swift Class Object
Swift Class Object
![Page 181: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/181.jpg)
& will continue over time
![Page 182: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/182.jpg)
let’s say we decide to go pure Swift and we re-write all of our view controllers
![Page 183: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/183.jpg)
without a re-factor, those Swift view controllers will interface with existing core logic layer
![Page 184: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/184.jpg)
and we’ll end up with a pure Swift codebase that doesn’t
use the safety features
![Page 185: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/185.jpg)
that’s crazy
![Page 186: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/186.jpg)
but you say, there’s a way around this…
![Page 187: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/187.jpg)
Objective-C Core Logic Superclass
Swift Core Logic Subclass
Objective-C View Controller Objective-C View Controller Swift View Controller
![Page 188: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/188.jpg)
why go through all these
gymastics?
![Page 189: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/189.jpg)
• Everyone on the team will have to understand this
• Requires a ton of discipline & deep understanding
![Page 190: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/190.jpg)
another way to look at it is…
![Page 191: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/191.jpg)
we’ll end up using only a portion of Swift,
![Page 192: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/192.jpg)
Accessible • Classes• Reference Semantics• Int backed Enums
Unaccessible • Generics• Tuples• Enumerations defined in Swift without Int raw
value type• Structures defined in Swift• Top-level functions defined in Swift• Global variables defined in Swift• Typealiases defined in Swift• Swift-style variadics• Nested types• Curried functions
![Page 193: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/193.jpg)
Yes, we can start at the bottom
![Page 194: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/194.jpg)
and yes, it will work
![Page 195: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/195.jpg)
but we’re not taking advantage of everything
Swift has to offer
![Page 196: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/196.jpg)
Ok, sidebar over…
![Page 197: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/197.jpg)
instead
![Page 198: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/198.jpg)
find new or existing vertical slices you can
write in Swift
![Page 199: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/199.jpg)
if it’s not clear where the vertical slices are…
![Page 200: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/200.jpg)
re-factor your Objective-C code first
![Page 201: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/201.jpg)
that’s safety
![Page 202: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/202.jpg)
Let’s talk Speed
![Page 203: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/203.jpg)
boils down to essentially no
runtime overhead
![Page 204: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/204.jpg)
that’s speed
![Page 205: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/205.jpg)
Knowing Swift’s strengths, you can improve your
existing apps with Swift code
![Page 206: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/206.jpg)
and gradually expand its surface area within
your project
![Page 207: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/207.jpg)
back to the journey…
![Page 208: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/208.jpg)
Ready to test!
![Page 209: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/209.jpg)
not so fast…
![Page 210: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/210.jpg)
Enterprise codesign
![Page 211: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/211.jpg)
Ready to ship!
![Page 212: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/212.jpg)
not so fast…
![Page 213: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/213.jpg)
Conditional Compile
![Page 214: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/214.jpg)
![Page 215: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/215.jpg)
![Page 216: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/216.jpg)
![Page 217: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/217.jpg)
#if Debug …
#elseif Release …
#endif
![Page 218: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/218.jpg)
Google #ifdef replacement in swift
![Page 219: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/219.jpg)
Time to cut release build and…
![Page 220: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/220.jpg)
ship it!
![Page 221: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/221.jpg)
![Page 222: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/222.jpg)
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
Maximize Benefits
![Page 223: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/223.jpg)
{2} Swift will Change
![Page 224: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/224.jpg)
![Page 225: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/225.jpg)
Then Apple released Swift 1.2
![Page 226: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/226.jpg)
it’s just a dot release
![Page 227: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/227.jpg)
piece of cake, there’s even a migrator :]
![Page 228: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/228.jpg)
‘cause it’s just a dot release
![Page 229: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/229.jpg)
right?
![Page 230: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/230.jpg)
nope!
![Page 231: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/231.jpg)
took two full days to migrate
![Page 232: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/232.jpg)
Swift is still evolving
![Page 233: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/233.jpg)
good news is…
![Page 234: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/234.jpg)
you don’t have to uptake new versions
immediately {for now}
![Page 235: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/235.jpg)
point is, you WILL run into this
![Page 236: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/236.jpg)
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
Maximize Benefits
![Page 237: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/237.jpg)
{3} Plan for the Future
![Page 238: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/238.jpg)
things are good
![Page 239: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/239.jpg)
time to think about the long haul
![Page 240: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/240.jpg)
Game plans
![Page 241: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/241.jpg)
Game plans
• Mixed Project
• Modularize
• Re-write (Go big or go home)
![Page 242: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/242.jpg)
Mixed Project Game plan
![Page 243: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/243.jpg)
Modularize Game plan
![Page 244: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/244.jpg)
UIApplication
UIApplicationDelegate
Persistence
Networking
Other Utilities
UIViewController UIView
VC VC
V V
VC
V
VC
V
VC
V
Persistence
Networking
Other Utilities
VC
V
VC
V
![Page 245: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/245.jpg)
UIApplication
UIApplicationDelegate
Persistence
Networking
Other Utilities
UIViewController UIView
Persistence
Networking
Other Utilities
VC
V
VC
V
Module / Cocoa Touch Framework
VC VC
V V
VC
V
VC
V
VC
V
![Page 246: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/246.jpg)
You Might Run Into
![Page 247: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/247.jpg)
You Might Run Into
• Exporting Module Maps
• Some system frameworks aren’t mapped to modules yet (common crypto, libxml, etc.)
![Page 248: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/248.jpg)
Google, “clang module map”
![Page 249: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/249.jpg)
Re-write Game plan
![Page 250: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/250.jpg)
You don’t have to re-write your app
![Page 251: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/251.jpg)
as a matter of fact you probably shouldn’t
![Page 252: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/252.jpg)
best game plan depends on your app’s architectural topology
![Page 253: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/253.jpg)
depends a lot on the size of the code base and how well architected/structured it is
![Page 254: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/254.jpg)
can you modularize it?
and how can you slice it?
![Page 255: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/255.jpg)
3 Gameplans
• Go big or go home
• Modularize
• Mixed
![Page 256: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/256.jpg)
we decided…
![Page 257: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/257.jpg)
Go big or go home
![Page 258: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/258.jpg)
Mordor
![Page 259: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/259.jpg)
this is the least practical path…
![Page 260: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/260.jpg)
but why not?
![Page 261: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/261.jpg)
we re-wrote all of our vertical slices
one by one
![Page 262: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/262.jpg)
UIApplication
UIApplicationDelegate
Persistence
Networking
Other Utilities
UIViewController UIView
VC
V
VC
V
P
N
O
P
N
O
VC
V
VC
V
P
N
O
VC
V
P
N
O
VC
V
P
N
O
![Page 263: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/263.jpg)
UIApplication
UIApplicationDelegate
UIViewController UIView
VC
V
VC
V
VC
V
VC
V
VC
V
Persistence
Networking
Other Utilities
![Page 264: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/264.jpg)
we made it!
![Page 265: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/265.jpg)
pure Swift goodness
![Page 266: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/266.jpg)
and we shipped it!!!
![Page 267: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/267.jpg)
![Page 268: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/268.jpg)
![Page 269: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/269.jpg)
Steps we took
• Identified Vertical Slices
• Re-wrote each vertical slice one at a time
• Maximized our use of Swift
![Page 270: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/270.jpg)
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
{1} Think Vertical
{2} Swift will Change
{3} Plan for the Future
Maximize Benefits
![Page 271: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/271.jpg)
Two Big Ideas
1. Learn by Doing, but not doing too much
2. Maximize Benefits
![Page 272: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/272.jpg)
that was quite a journey
![Page 273: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/273.jpg)
what happened next?
![Page 274: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/274.jpg)
new project
![Page 275: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/275.jpg)
pure Swift project
![Page 276: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/276.jpg)
having done mixed to full helped A TON
![Page 277: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/277.jpg)
we shipped that too…
![Page 278: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/278.jpg)
just a week ago
![Page 279: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/279.jpg)
and now we are here
![Page 280: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/280.jpg)
Whew…
![Page 281: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/281.jpg)
The Point
![Page 282: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/282.jpg)
learned a lot along the way without risking too
much at any time
![Page 283: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/283.jpg)
you can start writing Swift right now
without worrying
![Page 284: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/284.jpg)
you have options
![Page 285: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/285.jpg)
What Advice Can I Give?So what did I learn?
![Page 286: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/286.jpg)
What Advice Can I Give?
• What to learn first
• Objective-C consuming Swift interop
• Objective-C selectors in Swift
![Page 287: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/287.jpg)
What to learn first
![Page 288: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/288.jpg)
What to learn first
• Optionals, optionals, and optionals!
• Reference types vs Value types
• Initializers, BE CAREFUL
• Classes (inheritance, overrides, etc.)
• New Objective-C features (nullability, etc)
![Page 289: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/289.jpg)
Exposing Swift to Objective-C
![Page 290: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/290.jpg)
Objective-C can’t see pure Swift
![Page 291: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/291.jpg)
![Page 292: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/292.jpg)
Tips
![Page 293: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/293.jpg)
Avoid writing pure Swift code for
Objective-C components
![Page 294: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/294.jpg)
Stick to subclassing Apple framework classes
![Page 295: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/295.jpg)
or create your own Objective-C super
classes
![Page 296: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/296.jpg)
Objective C Superclass
Pure Swift Class, Struct, Enum
Swift subclass
Pure Swift Class, Struct, EnumPure Swift Class, Struct, Enum
Pure Swift Class, Struct, Enum
Objective C Consumer
Swift talks to Swift, Objective-C talks to
Objective-C
![Page 297: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/297.jpg)
![Page 298: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/298.jpg)
Yes, you CAN get Objective-C talking to
Swift classes, but why?
![Page 299: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/299.jpg)
Don’t have to wonder
• Can Objective-C take value types?
• Can Objective-C take my Swift enum?
• Can Objective-C take my closure?
• Do I need an adapter?
• etc.
![Page 300: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/300.jpg)
“If you never import a Swift class in Objective-C code, you
don’t need to worry about type compatibility” - Apple
![Page 301: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/301.jpg)
let’s talk Objective-C Selectors
![Page 302: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/302.jpg)
Swift is static, not dynamic
![Page 303: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/303.jpg)
we have to understand how Objective-C selectors work
in a static Swift world
![Page 304: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/304.jpg)
when to use @objc and @dynamic
![Page 305: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/305.jpg)
some quotes from our friends at Apple
![Page 306: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/306.jpg)
“Requiring @dynamic dispatch is rarely
necessary”
![Page 307: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/307.jpg)
“you must use the @dyanamic modifier when you know that
the implementation of an API is replaced at runtime"
![Page 308: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/308.jpg)
“If your Swift class inherits from an Objective-C class, all of the methods
and properties in the class are available as Objective-C selectors.”
![Page 309: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/309.jpg)
This is important when
• using target-action
• using Key Value Coding / Key Value Observing
• (oh no!) swizzling
![Page 310: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/310.jpg)
Wrapping up…
![Page 311: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/311.jpg)
I survived
![Page 312: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/312.jpg)
you can do it too
![Page 313: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/313.jpg)
you don’t have to jump in all at once
![Page 314: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/314.jpg)
do it your way, at your pace
![Page 315: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/315.jpg)
learn the language basics & interop
![Page 316: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/316.jpg)
so that then you can look at the benefits of Swift to improve your apps
![Page 317: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/317.jpg)
plan it out, be intentional
![Page 318: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/318.jpg)
you don’t have to re-write anything
![Page 319: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/319.jpg)
you don’t have to compromise your
team’s commitments
![Page 320: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/320.jpg)
there will be bumps
![Page 321: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/321.jpg)
you know what to expect
![Page 322: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/322.jpg)
you are ready
![Page 323: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/323.jpg)
New File… that’s all it takes
![Page 324: Bringing Swift into your Objective-C Projects](https://reader031.vdocuments.mx/reader031/viewer/2022022411/58e8fada1a28ab1f248b6279/html5/thumbnails/324.jpg)
Go Swift