Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Limited import clarification and its effect try! Swift Tokyo 2019 Tomoya Hirano @DeNA
Slide 2
Slide 2 text
Import
Slide 3
Slide 3 text
Import Declaration 1. attributes import module 2. attributes import module.submodule 3. attributes import importKind module.symbolName
Slide 4
Slide 4 text
Import Declaration 1. attributes import module 2. attributes import module.submodule 3. attributes import importKind module.symbolName
Slide 5
Slide 5 text
1. Attributes • Specify how to import symbols • Optional • @testable / @_exported
Slide 6
Slide 6 text
@testable • For testing and development. • Import internal methods as public.
Slide 7
Slide 7 text
@_exported • Import symbols as own code • Undocumented attributes
Slide 8
Slide 8 text
2. Submodule import 1. attributes import module 2. attributes import module.submodule 3. attributes import importKind module.symbolName
Slide 9
Slide 9 text
Example: SceneKit initializer
Slide 10
Slide 10 text
Example: SceneKit initializer
Slide 11
Slide 11 text
3. Kind import 1. attributes import module 2. attributes import module.submodule 3. attributes import importKind module.symbolName
Slide 12
Slide 12 text
struct class enum protocol typealias func let var 3. Kind import
Slide 13
Slide 13 text
3. Kind import • Individual import is only top-level • Cannot import overloaded functions separately
Slide 14
Slide 14 text
Example: Conflict method name
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
1. Attributes 2. Submodule import 3. Kind import Import Options
Slide 17
Slide 17 text
Can the build time be shortened?
Slide 18
Slide 18 text
4. Measuring the build times • made 100,000 methods • import Core vs import func Core.function0 • Tried 10 times
Slide 19
Slide 19 text
Basic Import Kind Import Average 277.645s 285.105s(+7.64s) Max 309.46s 312.99s(+3.53s) Min 273.48s 265.25s(-8.23s) Build time
Slide 20
Slide 20 text
Basic Import Kind Import Filesize 7336KB 7336KB Md5 0b10a59ce0a75decbb 2f120520c4fbc1 0b10a59ce0a75decbb 2f120520c4fbc1 Binary size
Slide 21
Slide 21 text
Build time Binary Size Namespace Simple Import Same Same Optional Kind specify Same Same Necessary Pros & Cons