6. 4
Programming in the 90s
~300 KB
•Storage is extremely expensive
•Slow / weak hardware
•Little to no access to decent internet (if at all)
Focus: High optimization
7. 5
349 MB
Programming today
Focus: Great experiences
•Storage is cheap (Base flagship iPhones have 128GB!)
•Fast / strong hardware
•High-speed internet is widely available
13. 8
Devices and data usage in emerging markets
🇧🇷🇮🇳🇨🇳🇲🇽🇹🇷, etc.
•Devices are usually older gen ones (16GB)
14. 8
Devices and data usage in emerging markets
🇧🇷🇮🇳🇨🇳🇲🇽🇹🇷, etc.
•Devices are usually older gen ones (16GB)
•Data can be prohibitively expensive and constrained
15. 8
Devices and data usage in emerging markets
🇧🇷🇮🇳🇨🇳🇲🇽🇹🇷, etc.
•Devices are usually older gen ones (16GB)
•Data can be prohibitively expensive and constrained
•Little to no access to decent internet (if at all)
19. 10
70% of people consider the size of
an app before downloading it
in 2017:
(Emerging markets)
20. 10
70% of people consider the size of
an app before downloading it
in 2017:
(85% of the world’s population)
21. 10
70% of people consider the size of
an app before downloading it
in 2017:
For every 6MB increase, install conversion drops by 1%
(Android)
(85% of the world’s population)
…which means
41. 18
Install Size != Download Size
Install Size
•Actual downloaded package may be smaller
42. 18
Install Size != Download Size
Install Size
•Actual downloaded package may be smaller
•Both can be predicted by generating an App
Thinning Size Report through Xcode
43. 18
Install Size != Download Size
Install Size
•Actual downloaded package may be smaller
•Both can be predicted by generating an App
Thinning Size Report through Xcode
•Companies usually focus on Install Size
specifically
65. Group 1
Group 2
Group 3
28
App Package
Swift
iOS
Hardware
Compiler
The iPhone Stack
Optimizing apps for size
66. Group 1
Group 2
Group 3
28
App Package
Swift
iOS
Hardware
Compiler
The iPhone Stack
Swift Overhead
Optimizing apps for size
67. Group 1
Group 2
Group 3
28
App Package
Swift
iOS
Hardware
Compiler
The iPhone Stack
Swift Overhead
Resources Overhead
Optimizing apps for size
68. Group 1
Group 2
Group 3
28
App Package
Swift
iOS
Hardware
Compiler
The iPhone Stack
Swift Overhead
Resources Overhead
Project/OS
Overhead
Optimizing apps for size
76. 30
Usingthewrong file formats
Resources Overhead
•Images: SVG for small icons, HEIC for everything else
•Text content, like JSONs: Sanitize them in order to remove
things you don’t need
77. 30
Usingthewrong file formats
Resources Overhead
•Images: SVG for small icons, HEIC for everything else
•Text content, like JSONs: Sanitize them in order to remove
things you don’t need
•Lottie animation JSONs have many fields that can be safely
stripped away
78. 30
Usingthewrong file formats
Resources Overhead
•Images: SVG for small icons, HEIC for everything else
•Audio: CAF (format) + AAC (codec) for short effects (Lossy)
•Text content, like JSONs: Sanitize them in order to remove
things you don’t need
•Lottie animation JSONs have many fields that can be safely
stripped away
79. 30
Usingthewrong file formats
Resources Overhead
•Images: SVG for small icons, HEIC for everything else
•Audio: CAF (format) + AAC (codec) for short effects (Lossy)
•For regular audio: try MP3 codecs with lower bit-rates
•Text content, like JSONs: Sanitize them in order to remove
things you don’t need
•Lottie animation JSONs have many fields that can be safely
stripped away
80. 30
Usingthewrong file formats
Resources Overhead
•Images: SVG for small icons, HEIC for everything else
•Audio: CAF (format) + AAC (codec) for short effects (Lossy)
•⚠ Warning: Audio is complicated!
•For regular audio: try MP3 codecs with lower bit-rates
•Text content, like JSONs: Sanitize them in order to remove
things you don’t need
•Lottie animation JSONs have many fields that can be safely
stripped away
95. 36
•Certain Swift patterns can be very expensive for app size
Swift Overhead
•Optimize for Size (-Osize)
•Whole Module Optimization
•Important: Make sure these flags are enabled in Xcode!
96. 36
•Certain Swift patterns can be very expensive for app size
Swift Overhead
•Optimize for Size (-Osize)
•Whole Module Optimization
•Important: Make sure these flags are enabled in Xcode!
•⚠ Be aware that this can affect performance
107. 40
Swift Overhead Improperusage ofstructs
This is a compiler issue. You should probably ignore this.
Optimization Tip (1):
Don’t forget about classes!
Still…
108. 40
Swift Overhead Improperusage ofstructs
This is a compiler issue. You should probably ignore this.
Optimization Tip (1):
Don’t forget about classes!
Optimization Tip (2):
Using SwiftUI? Be extra careful.
Still…
121. 46
Swift Overhead Unused code
•Unnecessary Dynamic Dispatching
•Potential impact: Several megabytes
122. 46
Swift Overhead Unused code
•Unnecessary Dynamic Dispatching
Optimization Tip (1):
Only add protocols if you truly need them
•Potential impact: Several megabytes
123. 46
Swift Overhead Unused code
•Unnecessary Dynamic Dispatching
Optimization Tip (1):
Only add protocols if you truly need them
•Potential impact: Several megabytes
124. 46
Swift Overhead Unused code
•Unnecessary Dynamic Dispatching
•Potential impact: Several megabytes
Optimization Tip (2):
Be familiar with Dynamic Dispatching in Swift
132. 50
•⚠ Requires dedicated infrastructure teams
•⚠ Often requires deep knowledge of Swift and iOS
Project/OS Overhead
133. 50
•⚠ Requires dedicated infrastructure teams
•⚠ Often requires deep knowledge of Swift and iOS
•⚠ Not something you would do for “individual" PRs
Project/OS Overhead
134. 50
•⚠ Requires dedicated infrastructure teams
•⚠ Often requires deep knowledge of Swift and iOS
•⚠ Not something you would do for “individual" PRs
Don’ttrythis at home!
Project/OS Overhead
138. 52
// Comment for string A
“stringA" = “Button”
// Comment for string B
“stringB" = “Another Button”
// Comment for string C
“stringC" = “Cool Button”
// Comment for string D
“stringD” = “Bad Button"
en.strings
// Comment for string A
“stringA" = “Botão”
// Comment for string B
“stringB" = “Outro Button”
// Comment for string C
“stringC" = “Botão Legal”
// Comment for string D
“stringD” = “Botão Ruim”
pt-BR.strings
Project/OS Overhead Xcode’s native localization is inefficient