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
ざっくりわかるSwift
Search
Shigure Shimotori
July 19, 2017
Programming
0
650
ざっくりわかるSwift
https://connpass.com/event/60103/
#TokyoTechLT
Shigure Shimotori
July 19, 2017
Tweet
Share
More Decks by Shigure Shimotori
See All by Shigure Shimotori
Synchronizationを支える技術
s_shimotori
1
160
1人で挑むSwiftコンパイラ 〜型システム入門編〜
s_shimotori
0
530
英語
s_shimotori
1
470
Parallel Socket Communication in Swift
s_shimotori
1
650
UIColor Anatomy
s_shimotori
1
2.3k
UIColor Cluster
s_shimotori
1
690
iOSDC Japan 2019 60 mins for color
s_shimotori
5
3.7k
wwdc19
s_shimotori
2
330
SE-0246 Generic Math(s) Functions
s_shimotori
2
2.4k
Other Decks in Programming
See All in Programming
Outline View in SwiftUI
1024jp
1
330
Enabling DevOps and Team Topologies Through Architecture: Architecting for Fast Flow
cer
PRO
0
340
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
230
CSC509 Lecture 11
javiergs
PRO
0
180
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
Amazon Qを使ってIaCを触ろう!
maruto
0
410
Remix on Hono on Cloudflare Workers
yusukebe
1
300
CSC509 Lecture 12
javiergs
PRO
0
160
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
900
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
110
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
340
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Gamification - CAS2011
davidbonilla
80
5k
Done Done
chrislema
181
16k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
900
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
A designer walks into a library…
pauljervisheath
204
24k
Into the Great Unknown - MozCon
thekraken
32
1.5k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
430
Faster Mobile Websites
deanohume
305
30k
Transcript
ͬ͘͟ΓΘ͔ΔSwift TokyoTech LT #2 @S_Shimotori
୭ʁ • @S_Shimotori (@S_Shimotori_pub) • ऑΤֶܥM2 • DroidKaigiӡӦελοϑ • SwiftPythonΛॻ͍͓ͯۚΛ͏͓ࣄ
DroidKaigi2018 ։࠵ܾఆʂ 20182݄8-9@ϕϧαʔϧ৽॓άϥϯυ https://droidkaigi.github.io/2018/
AndroidͱiOSͷڥͷҧ͍ • Android • ॳճ͚ͩొྉΛ͑OK • ຊAndroidͷձ͕͋Δɺֶੜ෦͋Δ • ࠓKotlin͕͍ʂ •
iOS • ຖ͓ࢪ͕ඞཁ • ͦΜͳձ͚͋ͬͨͬ • ·ͨSwift4ʹॻ͖͑Δ࡞ۀ͕͡·Δ͓…
ϞόΠϧͷҎ্ʂ
ຊ
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
Swiftͷจ๏ͷ֓ཁ
ཁ͢Δͱ͜Μͳ͔Μ͡ʂ • ϓϩτίϧࢦ / ΦϒδΣΫτࢦ / ؔܕ / ໋ྩܕ /
ϒϩοΫߏ • ڧ͍੩తܕ͚ / ܕਪ • Objective-C͔ΒͷӨڹ͋Γ • Swift4Ӷҙ࡞த • ܕ҆શnull҆શɻૉΒ͍͠ɻ • LLVMͱ͔ͳΜͱ͔ https://en.wikipedia.org/wiki/Swift_(programming_language)
ϓϩτίϧࢦʁ
Swiftyʹॻ্͘ͰѲ͓͖͍ͯͨ͜͠ͱ • SwiftʹclassͷଞʹstructɺenumɺprotocolΛ࣋ͭ • protocol”ಛఆͷॲཧͷͨΊͷϝιουͷઃܭਤ” • JavaͰ͍͏ͱ͜Ζͷinterface • ͭ·ΓΘͳͯ͘ಈ͔ͳ͍͜ͱͳ͍ •
Swift3ඪ४ϥΠϒϥϦͷ201γϯϘϧͷ͏ͪɺ struct140ݸɺenum12ݸɺprotocol48ݸɺ classͳΜͱ1ݸʂ
Java Comparable<T>ͱSwift Comparable • Java Comparable<T> • Swift Comparable μΠϚ
http://qiita.com/S_Shimotori/items/83e22d83f5c0096a6d5b http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/Comparable.java https://github.com/apple/swift/blob/c15c671372620b543e19a662218a247f601628e4/stdlib/public/core/Comparable.swift ※ ࣮ࡍEquatableͷ “=” ͱComparableͷ ”<“ Λ࣮͢ΕΓΔ
OptionalͱCommandLine • Optionalenum Optional<Wrapped> • .some(Wrapped)ͱ.noneΛྻڍ • Nullableͷਖ਼ମ • enum
CommandLineྻڍͯ͠ͳ͍ • ྻڍܕ͕ࣗΠχγϟϥΠζ͞Εͳ͍ಛੑΛར༻ https://github.com/apple/swift/blob/master/stdlib/public/core/CommandLine.swift https://github.com/apple/swift/blob/master/stdlib/public/core/Optional.swift Optional<String>ͷҥߏจ
ͪͳΈʹ: ԋࢉࢠΛఆٛ͢Δ • SwiftࣗͰԋࢉࢠΛఆٛ͢Δ͜ͱ͕Մೳ • ओʹؔܕ͍ͨ͠ਓ͕࡞Δ “>=“ • ͑Δه߸ແͦ͏ͳͭ •
/ = - + ! * % < > & | ^ ~ ?ͱ͔ଞ͍Ζ͍Ζ • ͑ʁ$͕ͩΊͳͷʹὺ͕͑Δͷʁʁ
ܕਪ͋ΔΜͩͶ͐ ͍͍ͪͪܕΛॻ͔ͳ͍͍ͯ͘Ͷʂ
SwiftͰܕਪͱ͍ͬͨΒ…… • ʮίϯύΠϧ࣌ؒͷେ͕ܕਪ͡ΌΜwʯ • ʮਪʹ͔͔͔࣌ؒͬͨΒίϯύΠϧఘΊ·ͨ͠Τϥʔʯ • ղܾࡦ: • ৽͍͠όʔδϣϯͷSwift(ͱXcode9)Λ͏ •
એݴ࣌ʹͪΌΜͱܕΛॻ͘ • ؔܕͳΜͯͳ͔ͬͨɻ͍͍Ͷʁ
ΤϥʔදݱͲ͏ͳͬͯΜͷʁ
Swiftʹ͓͚ΔΤϥʔදݱ • جຊతʹNonNullɺthrowͳ͠ • ޭ/ࣦഊͷ2ΓNullableͰදݱ • Optional.some(Wrapped)ͰแΜͰฦ͢ • Լॲཧ͠ͳ͍ͱแΜͩத͑ͳ͍ʂ •
ΑΓৄࡉͳΤϥʔදݱΛ͢ΔͳΒErrorΛ͛Δ • Τϥʔ͕ى͖ͳ͍͜ͱ͕໌Β͔ͳΒ”!”Ͱ௵͢
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
Swift͕͑Δॴ
͋ʔ͍͍iOSͶ ڵຯͳ͍ΜͰ✋
DarwinҎ֎Ͱ͑Δ͔Βʂ ͕͢͞ʹ2.2ݹ͍͕
LinuxͰSwift • swift.orgͷUbuntu༻όΠφϦ͔dockerΛ͏ͷָ͕ • Կ͔࡞Δ࣌Swift Package ManagerΛ͏ͱྑ͍ • ґଘؔղܾͨ͠Γςετͨ͠Γ͢Δ •
ίϚϯυϥΠϯπʔϧ͕࡞ΕΔ • WebϑϨʔϜϫʔΫͰWebΞϓϦ͕࡞ΕΔ • Perfectͱ͔Vaporͱ͔ͦͷΜ
ͱ͜ΖͰ
Swift͕Ͱ͖Δ͜ͱɺ୯ͰͰ͖ͳ͍͜ͱ • Swiftଂͷඪ४ϥΠϒϥϦ͕Ͱ͖Δ͜ͱ • هड़ʹඞཁͳػೳͷجຊ • Stringͱ͔printͱ͔ͦ͏͍͏ͷ • “import Foundation”ͰͰ͖Δ͜ͱ
• ΞϓϦͷجຊతͳػೳʹؔΘΔૢ࡞ • ϑΝΠϧͱ͔ηογϣϯͱ͔ͦ͏͍͏ͷ • Darwin༻FoundationͱLinux༻Foundationผ (༁)
swift-corelibs-foundationਐḿঢ়گ(7݄17ݱࡏ) https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md “Unimplemented”
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
CϥΠϒϥϦͷݺͼग़͠ (SPMͰͷ) iOS/macOSͬͱ͔ΜͨΜɻ
SPMͰCϥΠϒϥϦΛ͏ • ޙൃݴޠΒ͘͠ͲΜͲΜઌഐͷҨ࢈Λ͍ͬͯ͘ • Foundation͕ΞϨͳͷͰ͍ݹ͞ΕͨϥΠϒϥϦͷ ํ͕҆৺ • SPMͰϥοϓ͠ɺ1ͭͷύοέʔδͱͯ͠ѻ͏ • ґଘϦετʹSwiftͷͷCͷͷҰॹʹฒͿ
• ໊લΛCHogeͱ͢Δ׳ྫ͕͋Δ • cURLͳΒCCurlͱ͔
͕ൃੜ͢ΔΓํ ΅͘ͷߟ͍͖͑ͨ͞ΐ͏ͷ41.ύοέʔδ ύοέʔδ" ύοέʔδ# ύοέʔδ$ *#.4XJGU $$VSM 44IJNPUPSJ $$VSM D63-
·Ί͖ͪ͠: IBM͕ΜͬͯSwiftͯ͠Δɻ͍͍ͻͱɻ ໊લিಥ (ґଘݩˠґଘઌ)
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
Swiftʹ͍ͭͯ ͬͱΓ͍ͨͱ͖
ͱΓ͋͑ͣॻ͖ͳ͕ΒͬͯΈ͍ͨʂ • ԦಓXcodeͰߦ͖͍ͨਓ • Xcode8ʹϦϑΝΫλϦϯάػೳ͕ͳ͍(স) • playgroundsͰؾܰʹॻ͚Δɺͨͷ͍͠ • JetBrainsڭͷਓ •
iOSͱҰॹʹΔͳΒAppCodeɺpure SwiftͳΒCLion • Vimmer • ͪΌΜͱߋ৽͕͍͍ͭͯΔͷͳ͍Μ͡Ό… • Emacser • ͪΌΜͱߋ৽͞ΕͯΔɺͣΔ͍
͋ͱ͜ͷลಡΜͰ͓͘ͱ͍͍Αɻ • https://developer.apple.com/library/content/documentation/Swift/ Conceptual/Swift_Programming_Language/ • https://developer.apple.com/documentation/swift • https://swift.org/
·ͱΊ
Swiftͷ͕͍͜͜͢͝ʂ • ڧ͍੩తܕ͚ͰprotocolͰenumͰ͍͢͝ʂ • αʔόίϚϯυϥΠϯπʔϧ࡞ΕΔʂ • ͦΕPythonͰΑ͘ͳ͍ʁ • ಈతܕ͚அͯ͡Noɺઈରʹڐ͞ͳ͍ •
ͦΕGo • ͦͷՄೳੑ͋Δ • ͦΕKotlin • ૉͰAWSLambda͍͚ΔΜͩΜͳʔͣΔ͍Αͳʔ