Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Migrate to Swift 3
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
810
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
100
iOS Development with Ruby using RubyMotion
siuying
1
200
Other Decks in Programming
See All in Programming
Apache Hive: そしてCloud Native Lakehouseへ
okumin
1
220
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
680
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
ソフトウェア設計に溶けるインフラ ― AWS CDK のインフラ認識論
konokenj
3
770
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.8k
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
160
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
170
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
1.5k
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
100
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
260
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
150
数百円から始めるRuby電子工作
tarosay
0
140
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
370
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Designing for humans not robots
tammielis
254
26k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
760
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
340
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
480
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
The Cost Of JavaScript in 2023
addyosmani
55
10k
Statistics for Hackers
jakevdp
799
230k
Being A Developer After 40
akosma
91
590k
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