Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Migrate to Swift 3
Search
Francis Chong
July 14, 2016
Programming
210
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Migrate to Swift 3
Francis Chong
July 14, 2016
More Decks by Francis Chong
See All by Francis Chong
Implement beautiful DSL for iOS using Ruby
siuying
2
820
CocoaPods - A better way to use and publish open source project for Objective-C
siuying
2
390
Legco OpenData
siuying
0
140
EverClip - Evernote DEVCUP Meetup 2013 Hong Kong
siuying
0
110
iOS Development with Ruby using RubyMotion
siuying
1
210
Other Decks in Programming
See All in Programming
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
5
2.5k
LL言語やWebフレームワークのPostgreSQL対応 〜DBの機能がユーザーに届くまで〜
kentaroutakeda
0
140
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.8k
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
4.4k
AIエージェント時代のコードレビューを設計する
nogu66
6
2.6k
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
2.6k
WebMCP Challenge に星空観察アプリで参加した話
okajun35
0
120
iOS開発×AI駆動開発 〜最近使って便利だったスキルの話〜
nogu66
0
140
巨大モノリシックアプリ モダン化大作戦
ktcryomm
0
310
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
130
AIは賢い。でも実行環境は? CLIおじさんがAI時代に伝えたいこと ~ CLIおじさんがAI時代に伝えたいこと ~
curekoshimizu
1
220
業務時間外もAIに働いてもらう話
colorful12
3
10k
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
280
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
320
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
780
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Crafting Experiences
bethany
1
310
Code Reviewing Like a Champion
maltzj
528
40k
Transcript
MIGRATE TO SWIFT 3
FRANCIS CHONG @SIUYING
None
HTTPS://GETFINCH.ES
▸ Swift evolution ▸ What's new in Swift 3 ▸
Migration to Swift 3
SWIFT EVOLUTION
SWIFT 1
None
None
None
NSString* content = [[[listItemView text] text] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]] let
content = listItemView.text.stringByTrimmingCharactersInSet( NSCharacterSet.whitespaceAndNewlineCharacterSet())
NEW LANGUAGE OPTIMIZED FOR EASY TRANSITION
SWIFT 2
SWIFT 2.0 ▸ Error Handling
SWIFT 2.0 ▸ Error Handling ▸ Protocol Extension
SWIFT 2.0 ▸ Error Handling ▸ Protocol Extension ▸ #available(iOS
9.0, *)
SWIFT 2.0 ▸ Error Handling ▸ Protocol Extension ▸ #available(iOS
9.0, *) ▸ nullability in UIKit/AppKit
SWIFT 2.2 ▸ #if(swift>=2.0)
SWIFT 2.2 ▸ #if(swift>=2.0) ▸ #selector
SWIFT 2.2 ▸ #if(swift>=2.0) ▸ #selector ▸ deprecated C style
loops
NEW IDEAS WITH COMPATIBILITY
SWIFT 3
WHAT'S NEW IN SWIFT 3
GRAND RENAMING
GRAND RENAMING ▸ API Design Guidelines
GRAND RENAMING ▸ API Design Guidelines ▸ Apply API Guidelines
to the Standard Library
GRAND RENAMING ▸ API Design Guidelines ▸ Apply API Guidelines
to the Standard Library ▸ Better Translation of Objective-C APIs Into Swift
FIRST PARAMETER // Swift 2 func moveToPoint(_: CGPoint) moveToPoint(point)
FIRST PARAMETER // Swift 2 func moveToPoint(_: CGPoint) moveToPoint(point) //
Swift 3 func move(to point: CGPoint) move(to: point)
CAPITALIZATION ON ENUM CASES // Swift 2 UIInterfaceOrientationMask.Landscape NSTextAlignment.Right
CAPITALIZATION ON ENUM CASES // Swift 2 UIInterfaceOrientationMask.Landscape NSTextAlignment.Right //
Swift 3 UIInterfaceOrientationMask.landscape NSTextAlignment.right
OMIT NEEDLESS WORDS // Swift 2 let content = listItemView.text.stringByTrimmingCharactersInSet(
NSCharacterSet.whitespaceAndNewlineCharacterSet())
OMIT NEEDLESS WORDS // Swift 2 let content = listItemView.text.stringByTrimmingCharactersInSet(
NSCharacterSet.whitespaceAndNewlineCharacterSet()) // Swift 3 let content = listItemView.text.trimming(.whitespaceAndNewlines)
MODERNIZED GCD // Swift 2 let queue = dispatch_queue_create("com.test.myqueue", nil)
dispatch_async(queue) { print("Hello World") }
MODERNIZED GCD // Swift 2 let queue = dispatch_queue_create("com.test.myqueue", nil)
dispatch_async(queue) { print("Hello World") } // Swift 3 let queue = DispatchQueue(label: "com.test.myqueue") queue.async { print("Hello World") }
MODERNIZED COREGRAPHICS // Swift 2 let ctx = UIGraphicsGetCurrentContext() let
rectangle = CGRect(x: 0, y: 0, width: 512, height: 512) CGContextSetFillColorWithColor(ctx, UIColor.blueColor().CGColor) CGContextSetStrokeColorWithColor(ctx, UIColor.whiteColor().CGColor) CGContextSetLineWidth(ctx, 10) CGContextAddRect(ctx, rectangle) CGContextDrawPath(ctx, .FillStroke) UIGraphicsEndImageContext()
MODERNIZED COREGRAPHICS // Swift 3 if let ctx = UIGraphicsGetCurrentContext()
{ let rectangle = CGRect(x: 0, y: 0, width: 512, height: 512) ctx.setFillColor(UIColor.blue().cgColor) ctx.setStrokeColor(UIColor.white().cgColor) ctx.setLineWidth(10) ctx.addRect(rectangle) ctx.drawPath(using: .fillStroke) UIGraphicsEndImageContext() }
OPTIMIZED FOR ELOQUENT SWIFT
SHOULD I MIGRATE?
SHOULD I MIGRATE? ▸ New project
SHOULD I MIGRATE? ▸ New project ▸ Objective-C project with
some Swift code?
SHOULD I MIGRATE? ▸ New project ▸ Objective-C project with
some Swift code? ▸ Swift 2 project with no Dependencies?
SHOULD I MIGRATE? ▸ New project ▸ Objective-C project with
some Swift code? ▸ Swift 2 project with no Dependencies? ▸ Swift 2 project with many external dependencies?
WHAT VERSION SHOULD I MIGRATE?
YOU CANNOT MIXED SWIFT 2.2/2.3/3.0 IN SAME PROJECT
PRE MIGRATION
MIGRATE YOUR DEPENDENCIES pod 'HidingNavigationBar', git: "https://github.com/siuying/HidingNavigationBar.git", branch: "swift3" pod
'CocoaLumberjack/Swift', git: "https://github.com/siuying/CocoaLumberjack.git", branch: "xcode8" pod 'UIColor_Hex_Swift', git: "https://github.com:e-Sixt/UIColor-Hex-Swift.git", branch: "Swift-3.0" pod 'RxSwift', git: "https://github.com/ReactiveX/RxSwift.git", branch: "swift-3.0" pod 'RxDataSources', git: "https://github.com/siuying/RxDataSources.git", branch: "swift3" pod 'RxOptional', git: "https://github.com/RxSwiftCommunity/RxOptional.git", branch: "swift-3.0"
ONLY UPDATE YOUR OWN PROJECT
MIGRATOR ▸ Rename Foundation classes ▸ Rename enum and static
names ▸ Rename methods and fields ▸ Replace changed code (Collection/Dispatch/CoreGraphics)
POST MIGRATION ▸ Fix compile error ▸ Read API Design
Guidelines ▸ Update to API Design Guidelines
POST MIGRATION ▸ Fix compile error ▸ Read API Design
Guidelines ▸ Update to API Design Guidelines
The End