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.1k
waiwai-swiftpm-part2
d_date
3
460
わいわいSwift PM part 1
d_date
2
370
What's new in Firebase 2021
d_date
2
1.4k
CI/CDをミニマルに構築する
d_date
1
530
Swift Package centered project - Build and Practice
d_date
20
13k
How to write Great Proposal
d_date
4
1.1k
Thinking about Architecture for SwiftUI
d_date
8
2.3k
Integrate your app to modern world in Niigata
d_date
0
620
Other Decks in Programming
See All in Programming
cmp.Or に感動した
otakakot
3
180
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.6k
イベント駆動で成長して委員会
happymana
1
320
アジャイルを支えるテストアーキテクチャ設計/Test Architecting for Agile
goyoki
9
3.3k
Compose 1.7のTextFieldはPOBox Plusで日本語変換できない
tomoya0x00
0
190
Jakarta EE meets AI
ivargrimstad
0
630
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
距離関数を極める! / SESSIONS 2024
gam0022
0
280
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
920
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
230
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
880
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
930
Featured
See All Featured
For a Future-Friendly Web
brad_frost
175
9.4k
Adopting Sorbet at Scale
ufuk
73
9.1k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Teambox: Starting and Learning
jrom
133
8.8k
Rails Girls Zürich Keynote
gr2m
94
13k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Automating Front-end Workflow
addyosmani
1366
200k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
GraphQLとの向き合い方2022年版
quramy
43
13k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
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