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
[SE-0160] Limiting @objc inference
Search
d_date
April 13, 2017
Programming
2
2.4k
[SE-0160] Limiting @objc inference
2017/04/13(木) Potatotips #39
d_date
April 13, 2017
Tweet
Share
More Decks by d_date
See All by d_date
TCA Practice in 5 min
d_date
2
1.3k
waiwai-swiftpm-part2
d_date
3
470
わいわいSwift PM part 1
d_date
2
380
What's new in Firebase 2021
d_date
2
1.4k
CI/CDをミニマルに構築する
d_date
1
540
Swift Package centered project - Build and Practice
d_date
20
13k
How to write Great Proposal
d_date
4
1.2k
Thinking about Architecture for SwiftUI
d_date
8
2.3k
Integrate your app to modern world in Niigata
d_date
0
630
Other Decks in Programming
See All in Programming
毎日13時間もかかるバッチ処理をたった3日で60%短縮するためにやったこと
sho_ssk_
1
500
rails newと同時に型を書く
aki19035vc
5
620
AppRouterを用いた大規模サービス開発におけるディレクトリ構成の変遷と問題点
eiganken
1
410
Package Traits
ikesyo
1
160
return文におけるstd::moveについて
onihusube
1
1.4k
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
630
Fibonacci Function Gallery - Part 2
philipschwarz
PRO
0
200
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
330
Go の GC の不得意な部分を克服したい
taiyow
3
990
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
600
Androidアプリの One Experience リリース
nein37
0
760
선언형 UI에서의 상태관리
l2hyunwoo
0
250
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
How GitHub (no longer) Works
holman
312
140k
The Invisible Side of Design
smashingmag
299
50k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.5k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Building Adaptive Systems
keathley
38
2.3k
Transcript
[SE-0160] Limiting @objc inference Daiki Matsudate (@d_date) potatotips #39
None
None
None
Agenda • ͱͯ140จࣈͰπΠʔτͰ͖ͳ͍ • [SE-0160] Limiting @objc inferenceʹ͍ͭͯ ͠·͢ɻ
[SE-0160] @objcਪͷ੍ݶ • https://github.com/apple/swift-evolution/ blob/master/proposals/0160-objc- inference.md
@objc in Swift 3.x • Objective-CͰݺͼग़ͤΔͷʹ͍ͭͯɺSwift ଆͰ໌ࣔతʹએݴͰ͖Δ • Θ͟Θ͟@objcΛॻ͔ͳ͍͍ͯ͘Α͏ʹ ਪͯ͘͠ΕΔ
@objc in Swift 3.x ͷ • Objective-CͰݺͼग़ͤΔͷʹ͍ͭͯɺSwift ଆͰ໌ࣔతʹએݴͰ͖Δ • Θ͟Θ͟@objcΛॻ͔ͳ͍͍ͯ͘Α͏ʹ
ਪͯ͘͠ΕΔ → աͰʁʁ
@objc in Swift 3.x ͷ • SwiftͷΫϥεObjective-CͷSelectorͷিಥΛ Ҿ͖ى͕ͪ͜͠
@objc in Swift 3.x ͷ • Swift API Design GuidelineʹԊͬͯॻ͍ͯɺ
Objective-CͰݺͼग़͢ͱ͖ʹObjective-C Coding Guidelineʹ͢Δ໊લʹม͞Ε͕ͪɻ ಛʹɺinitializerɺͦͷ໊લʹୈҰҾΛؚΊͳ ͍͚ͯ͘ͳ͍ͷͰɺ@objcඞ͚ͣͭΔ͜ͱʹ ͳΔɻ
• SwiftίϯύΠϥObjective-C Calling Convention͔ΒSwift Calling Conventionม ͢Δ"thunk"ϝιουΛ࡞ΔͨΊɺόΠφϦαΠζ ͕૿େ͢Δɻ @objc in
Swift 3.x ͷ
@objc in future
@objc in future Objective-CͰඞཁͳͱ͜Ζ͚ͩʹ@objcΛ ͚ͭΔΑ͏ʹਪΛݮΒ͢ ʲํʳ
Ҿ͖ଓ͖@objcΛਪ͢Δͷ 1.@objcͷ͍͍ͭͯΔએݴͷΦʔόʔϥΠυͷͱ͖
Ҿ͖ଓ͖@objcΛਪ͢Δͷ 2. @objcͷ͍ͭͨϓϩτίϧͷཁ݅Λຬͨ͢ͱ͖
Ҿ͖ଓ͖@objcΛਪ͢Δͷ 3. @IBOutlet,@IBActionଐੑ͕͍͍ͭͯΔͱ͖ 4. @NSManagedଐੑ͕͍͍ͭͯΔͱ͖ Interface BuilderͱͷΠϯλϥΫγϣϯ͕ Objective-CϥϯλΠϜͰߦΘΕΔͨΊ Core DataͱͷΠϯλϥΫγϣϯ͕
Objective-CϥϯλΠϜͰߦΘΕΔͨΊ
ՃͰ@objcΛਪ͢Δͷ 1. @GKInspectableଐੑ͕͍͍ͭͯΔͱ͖ 2. @IBInspectableଐੑ͕͍͍ͭͯΔͱ͖ GameplayKitͱͷΠϯλϥΫγϣϯ͕ Objective-CϥϯλΠϜͰߦΘΕΔͨΊ Interface BuilderͱͷΠϯλϥΫγϣϯ͕ Objective-CϥϯλΠϜͰߦΘΕΔͨΊ
@objcΛਪ͠ͳ͘ͳΔͷ 1. dynamic
@objcΛਪ͠ͳ͘ͳΔͷ 2. NSObject༝དྷͷΫϥε NSObjectΛܧঝ͍ͯ͠ΔΫϥεͰ͋ͬͯɺ @objcͳ͠ͰObjective-C͔Βݺͼग़ͤͳ͍ɻ
@objcΛਪ͠ͳ͘ͳΔͷ 2. NSObject༝དྷͷΫϥε extensionͰɺ@objcͳ͠ͰObjective-C͔Βݺͼ ग़ͤͳ͍ɻ
@objcMembersͷಋೖ XCTestͳͲɺΫϥεશମ͕@objcͰ͋Δ͜ͱ͕ٻΊΒ ΕΔࡍɺ@objcMembersΛ͚ͭΔ
@objcMembersͷಋೖ @objcMembersΛ͚ͭΔΫϥεɺObjecive-Cଆ Ͱ swift_objc_membersΛ͚ͭΔ
Extensionʹ͓͚Δ@objcͷON/OFF @nonobjcΛextensionʹ͚ͭΔ͜ͱͰɺ@objcͷ ର֎ͱ͢Δ͜ͱ͕Ͱ͖Δɻ
Swift 4Ҡߦͷͱ͖ Ͳ͏͢Ε͍͍ͷ…ʁ
"Minimal" migration workflow
Minimal migration workflow • Step 1: Swift 4ϞʔυͰɺ@objcਪ͞ΕͨՕॴͷ͢ ͯͷܯࠂΛղফ͢Δɻ
Minimal migration workflow • Step 2: SWIFT_DEBUG_IMPLICIT_OBJC_ENTRYPOINTΛ1ʙ3 ͷؒͷʹઃఆ͠ɺΞϓϦΛςετɻ 1.ΤϯτϦϙΠϯτͷݺग़ΛϝοηʔδͰه 2.ϩάΛͱΓɺόοΫτϨʔεΛൃߦ
3.όοΫτϨʔεͰه͠ɺΫϥογϡ͠·͢ɻ
Minimal migration workflow • Step 3: ͜ͷ࣌ͰɺSwift 4ʹҠߦՄೳɻSwift 4ΛϏϧ υ͢Δͱɺഇࢭ༧ఆͷϧʔϧʹج͍ͮͯ@objc
͕ਪଌ͞ΕͨΓͷέʔεͷObjective-CΤϯτ ϦϙΠϯτ͕আ͞ΕΔɻ
·ͱΊ • dynamic, NSObject༝དྷͷΫϥεͰ@objcਪ ͕͞Εͳ͘ͳΔ • @objcMembersʹΑΓclassશମʹ@objcΛదԠ Ͱ͖ΔΑ͏ʹͳΔ • @nonobjcΛextensionʹదԠ͢Δ͜ͱͰͦͷ
extension@objcͷదԠ֎ͱ͢Δ͜ͱ͕Ͱ͖Δ
એ
Thank you