Understanding iOS from an
Android perspective
A Busy Developer’s Guide to native iOS apps
Lauren Yew
Sept 28th, 2021
The New York Times
?
Let’s start
with a caveat
PetAdopt Sample App
iOS Android
Topics
1. Design Differences
2. Swift vs. Kotlin
3. App Setup & Structure
4. App Lifecycles & Architecture Patterns
5. SwiftUI vs. Jetpack Compose
?
Topics
1. Design Differences
2. Swift vs. Kotlin
3. App Setup & Structure
4. App Lifecycles & Architecture Patterns
5. Swift UI vs. Jetpack Compose
Design Differences
iOS Android
Apple Human Interface
Guidelines
Material Design
Design Differences
iOS Android
Home Button Only
Home Button + Back Button
(*sometimes represented by gestures
depending on navigation settings)
Back Buttons
iOS Android
Back Button
always present
No Back Button
iOS
Selection Options
Android
iOS
Selection Options
Android
Switch per option
iOS
Errors
Android
Topics
1. Design Differences
2. Swift vs. Kotlin
3. App Setup & Structure
4. App Lifecycles & Architecture Patterns
5. Swift UI vs. Jetpack Compose
Swift
Declaring Variables
Kotlin
Swift
Declaring Variables
Kotlin
Swift
Optionals
Kotlin
Swift
Optionals
Kotlin
Optional Chaining Safe Call
Swift
Optionals
Kotlin
Nil Coalescing Elvis Operator
Swift
Optionals
Kotlin
Swift
Optionals
Kotlin
Swift
Optionals
Kotlin
Force Unwrap
Required each
time.
Guard + Let
Pattern of
Early Exit
Swift
Guard + Let
Swift
Swift
Functions
Kotlin
Swift
Functions
Kotlin
Swift
Functions
Kotlin
Parameter
names required
unless have _
Swift
Protocols
Kotlin
Swift
Protocols
Kotlin
Swift
Protocols
Kotlin
Struct Class
Swift
Structs vs. Classes
Swift
Structs vs. Classes
Struct Class
Swift
Structs vs. Classes
Swift Kotlin
Class Inheritance
Same
Module
Same /
Different
Module
Class Inheritance
Swift Kotlin
Different
Module
Same /
Different
Module
• All protocols, classes, and structs
are extendable.
• Expect extensions on classes to
help modularize the code (within
the same class or in other
classes)
• Search by class name to find
where it has been extended
Swift
Extensions
Topics
1. Design Differences
2. Swift vs. Kotlin
3. App Setup & Structure
4. App Lifecycles & Architecture Patterns
5. Swift UI vs. Jetpack Compose
...
Xcode Basics
Opening a workspace
Project
Workspace
*always use this option if it’s
available
Workspace
What documents / projects do I contain?
At a high level
Project Project
Represents
app/library/framework.
What are the source
documents, file structure, and
basic project wide settings?
Project
Target
Target
Target
How to build / run each
app / library?
Target
Target
Projects and Targets in Xcode
Projects and Targets in Xcode
Projects and Targets in Xcode
Projects and Targets in Xcode
Projects and Targets in Xcode
Projects and Targets in Xcode
iOS App Structure
Terminology
• Bundle (represents executable app /
framework)
• Framework = library module
• Application Bundle: Info.plist, executable,
& resource files
Info.plist
• Information Property List (similar
to AndroidManifest + parts of
build.gradle)
• XML file encoded w/ UTF-8
Info.plist
Working w/ Dependencies (Cocoapods)
Another option: SPM (Swift
Package Manager)
Working w/ Dependencies
Cocoapods (iOS) Gradle (Android)
Working w/ Dependencies
Cocoapods (iOS) Gradle (Android)
Working w/ Dependencies
Cocoapods (iOS) Gradle (Android)
Working w/ Dependencies (Cocoapods)
Central Repository
(trunk)
How does Cocoapods Work?
Popular iOS Third Party Libraries
• Alamofire / AFNetworking (HTTP calls)
• Lottie (Image Rendering)
• RxSwift (RxJava for Swift) or just use Combine
• YapDatabase (Sqlite Database – similar to Room)
• Resolver (Dependency Injection – similar to Hilt)
Topics
1. Design Differences
2. Swift vs. Kotlin
3. App Setup & Structure
4. App Lifecycles & Architecture Patterns
5. Swift UI vs. Jetpack Compose
......
Main iOS App Lifecycles
Not Running
App is in foreground
Inactive
Active
App is in background
Background
Suspended
Handling iOS App Lifecycles
callbacks for lifecycle
callbacks windows / UI lifecycles
SwiftUI Apps
This is an example of a SwiftUI app entry point w/ @main
App can be configured to use AppDelegate
Scene replaces SceneDelegate
UIViewController / Non-Swift UI
Main iOS App Lifecycles
Not Running
Finished launching,
next step to come into
foreground
Main iOS App Lifecycles
Not Running
App is in foreground
Inactive
Main iOS App Lifecycles
App is in foreground
Inactive
Active
Main iOS App Lifecycles
App is in foreground
Inactive
Active
Architecture Patterns
Common Architecture Patterns
• MVC (Model View Controller) aka. Massive View Controller
• MVP (Model View Presenter)
• MVVM (Model View ViewModel)
• VIPER (View, Interactor, Presenter, Entity, & Router)
MVVM on iOS
• No viewModel is built in with iOS
• POJO w/ properties and/or
functions for view to react on or
update
• Up to devs to determine how
much business logic in
viewModel
Topics
1. Design Differences
2. Swift vs. Kotlin
3. App Setup & Structure
4. App Lifecycles & Architecture Patterns
5. Swift UI vs. Jetpack Compose
!
Basic Structure
SwiftUI Jetpack Compose
Columns & Rows
SwiftUI Jetpack Compose
Columns & Rows
SwiftUI Jetpack Compose
Modifiers
SwiftUI Jetpack Compose
Getting Data to the UI
SwiftUI Jetpack Compose
Getting Data to the UI
SwiftUI Jetpack Compose
Getting Data to the UI
SwiftUI Jetpack Compose
Thank You
@YewLauren
Appendix
The New York Times is Hiring!
NYT Android & iOS Apps (News, Cooking, Games)
Come work with us.
https://www.nytco.com/careers/
Resources
• https://learnui.design/blog/ios-vs-android-app-ui-design-complete-guide.html
• https://uxdesign.cc/ios-vs-android-design-630340a73ee6
• https://willowtreeapps.com/ideas/swift-and-kotlin-the-subtle-differences
• https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundl
es/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW1
• https://developer.apple.com/videos/play/wwdc2018/415/
• https://manasaprema04.medium.com/application-life-cycle-in-ios-f7365d8c1636
• https://www.vadimbulavin.com/swiftui-view-lifecycle/
• https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_
ui_to_run_in_the_background
• https://learnappmaking.com/swiftui-app-lifecycle-how-to/
• https://www.vadimbulavin.com/swiftui-view-lifecycle/
• https://kotlinlang.org/docs/keyword-reference.html#special-identifiers
• https://medium.com/swlh/bye-bye-appdelegate-swiftui-app-life-cycle-58dde4a42d0f
• PetAdopt Sample App: https://github.com/laurenyew/PetAdoptSampleApp/tree/develop/ios
Back Buttons
iOS Android
Back Button w/
Title
Back Buttons
iOS Android
Hit back button
iOS
Main Action Button
Android
+ on right
Floating Action
Button
iOS
Primary Navigation
Android
Tab Bar
Top nav buttons
Swift
Structs vs. Classes
Struct Class
iOS
• Lists are Tables
• SwiftUI à List {…}
• Lists are RecyclerViews +
Adapters / ListViews
• JetpackCompose à Lists are
LazyColumns
Lists
Android
ARC vs Garbage Collection
• ARC = automatic reference counting
• Improved performance (any numbers?)
• How it works? Counts number of references on a class then if number
is 0, removes that bit of data, unlike Garbage collection that waits till a
moment in time then cleans up things that don’t have references
• Requirements for weak self in closure (similar to do not pass context
references) ß needs code example
Loading up an Application
• .xcodeproj file (list of files / objects for
xcode to load) – grouped by type
• Xcode builds application w/ configuration on
`target` with rules to build bundle from
Info.plist + source files
• Compile task: takes source code (.h, .m,
.swift) and makes into object files (.o)
• Link task: links object files to make
executable library output file (.app)
SwiftUI Lifecycles
Appearing
Layout
Commit
SwiftUI Lifecycles
Updating
Diff
Update Body and re-
render required UI
SwiftUI Lifecycles
Disappearing
On Disappear
iOS
Modularizing
Android
Extra Modularizing
How does Cocoapods Work?
How does Cocoapods Work?
On Background
• Save User State / Data
• Suspend dispatch / operation queues
• Don’t start any new tasks
• App will take snapshot image of current state
to show when app is starting back up
(*Android also does this)
App Manager

Understanding iOS from an Android perspective