SlideShare a Scribd company logo
Mohammad Azam
Lessons Learned from Building
SwiftUI Apps
@azamsharp
About Me
• Mohammad Azam
• iOS Developer
• Coding bootcamp instructor
• Instructor on Udemy & LinkedIn
• Author and speaker
Agenda
• SwiftUI Architectures
• SwiftUI & Core Data
• Testing
• View Events
• Environment Slicing
• Evaluating vs Rendering
• SwiftUI & UIKit
This is NOT application
architecture advice!
Which pattern should I use?
https://www.linkedin.com/pulse/why-people-become-blind-followers-ameya-agrawal/
Client/Server
Apps
MovieListView MovieDetailScreen ReviewListScreen
AddReviewScreen
AddMovieScreen
MoveListViewModel
MovieViewModel
MovieDetailViewModel
AddMovieViewModel
ReviewListViewModel
ReviewViewModel
AddReviewViewModel
Dependency Injection
XAML
C#
WPF
AddMovieView
AddMovieView
! !
HTML Client Side Form Validation
AddMovieEditConfig
View is the View Model
Declaration of what
you want to be
displayed on the
screen
SwiftUI
Not actual HTML
elements. These are
Virtual DOM elements
managed by React.
React
Consuming API
@State and .task
Aggregate Root Model
WWDC 2020: Data Essentials in SwiftUI
Apple’s sample apps
Fruta and FoodTruck
Aggregate Root Model
@EnvironmentObjec
t
@EnvironmentObjec
t
MovieListViewModel
MovieViewModel
MovieDetailViewModel
AddMovieViewModel
ReviewListViewModel
ReviewViewModel
AddReviewViewModel
MVVM MV
Aggregate Model
Code is not an asset,
it is a liability
Bigger
Apps?
Multiple Aggregate Root objects based
on the bounded context of the application
Do your research!
MovieListView
AddMovieView
Sheet
onDismiss
NSFetchedResultsController
Don’t fight the framework?
@FetchRequest
@SectionedFetchRequest
NHibernate
LINQ to SQL
Entity Framework
Sequelize
Light Speed
Active Record Pattern
Base Model and Concrete Implementations
SwiftUI + Core Data
Active Record Pattern
Xcode Previews
Container Views
🙂
Structure your app for SwiftUI previews - WWDC20
Testin
g
LoginView Form Validation
But I really want to write a test!!!
LoginView
Don’t write unit test for your View Model to verify
the user interface.
👎🏼
👍🏼
Test behavior not implementation details
If the implementation details change, the test will fail
Don’t use mocks for managed dependency
Test is the isolation, not the thing under
test
- Ian Cooper
Rendering vs
Evaluation
body is being evaluated
The only view that is using
the @State count
SwiftUI does not recreate the
whole ContentView. It only
renders the views that needs
to be updated.
VStack
Text(“Counter”) Text(count
)
Button List
Simplified Tree representation of our ContentView
VStack
Text(“Counter”) Text(count
)
Button List
Only one of the Text views is using the @State count
property
VStack
Text(“Counter”) Text(count
)
Button List
SwiftUI destroys that view and recreates it again
Slicing Environment Objects
Programmatic Navigation
Programmatic Navigation
Usage
Date Formatting
List Formatting
Xcode Previews for UIKit
Injecting SwiftUI View into a UIKit App and Handling Events
Final thoughts
• SwiftUI is the future of app development
• Don’t fight the framework
• Read Apple’s documentation on SwiftUI
• Watch WWDC videos to get better understanding
• I don’t know which architecture is best. Try out different ones and see which
one works for your needs.
https://azamsharp.com/books
Free books
https://azamsharp.com/nyswifty2023
References & Slides
https://www.slideshare.net/secret/1QsYpS5AFGz3cu
Contact
• azamsharp@gmail.com
• @azamsharp
• www.azamsharp.com
• https://www.udemy.com/user/mohammad-azam-2/
Lessons-Learned-SwiftUI.pptx
Lessons-Learned-SwiftUI.pptx

More Related Content

What's hot

Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
guest11106b
 

What's hot (20)

Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
 
Swift UI - Declarative Programming [Pramati Technologies]
Swift UI - Declarative Programming [Pramati Technologies]Swift UI - Declarative Programming [Pramati Technologies]
Swift UI - Declarative Programming [Pramati Technologies]
 
Reactjs
Reactjs Reactjs
Reactjs
 
React Native - Getting Started
React Native - Getting StartedReact Native - Getting Started
React Native - Getting Started
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
introduction to flutter ppt - free download
introduction to flutter ppt - free downloadintroduction to flutter ppt - free download
introduction to flutter ppt - free download
 
Intro To React Native
Intro To React NativeIntro To React Native
Intro To React Native
 
Intro to react native
Intro to react nativeIntro to react native
Intro to react native
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react native
 
React JS
React JSReact JS
React JS
 
React Native
React NativeReact Native
React Native
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
React Native Workshop
React Native WorkshopReact Native Workshop
React Native Workshop
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Spring boot
Spring bootSpring boot
Spring boot
 
Hybrid Mobile App
Hybrid Mobile AppHybrid Mobile App
Hybrid Mobile App
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
 

Similar to Lessons-Learned-SwiftUI.pptx

Universal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Universal programming recipes​ - Ekaterina Trofimenko - Women In TechnologyUniversal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Universal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Badoo
 
Prototyping app using JS and HTML5 (Ciklum Kharkiv)
Prototyping app using JS and HTML5 (Ciklum Kharkiv)Prototyping app using JS and HTML5 (Ciklum Kharkiv)
Prototyping app using JS and HTML5 (Ciklum Kharkiv)
Yuriy Silvestrov
 

Similar to Lessons-Learned-SwiftUI.pptx (20)

Visual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonVisual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot Comparison
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Colorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latestColorful world-of-visual-automation-testing-latest
Colorful world-of-visual-automation-testing-latest
 
"Universal programming recipes", Kateryna Trofimenko
"Universal programming recipes", Kateryna Trofimenko"Universal programming recipes", Kateryna Trofimenko
"Universal programming recipes", Kateryna Trofimenko
 
Universal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Universal programming recipes​ - Ekaterina Trofimenko - Women In TechnologyUniversal programming recipes​ - Ekaterina Trofimenko - Women In Technology
Universal programming recipes​ - Ekaterina Trofimenko - Women In Technology
 
The 2014 Decision Makers Guide to Java Web Frameworks
The 2014 Decision Makers Guide to Java Web FrameworksThe 2014 Decision Makers Guide to Java Web Frameworks
The 2014 Decision Makers Guide to Java Web Frameworks
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with Knockoutjs
 
Swiz DAO
Swiz DAOSwiz DAO
Swiz DAO
 
Learn react the right way
Learn react the right way  Learn react the right way
Learn react the right way
 
Prototyping app using JS and HTML5 (Ciklum Kharkiv)
Prototyping app using JS and HTML5 (Ciklum Kharkiv)Prototyping app using JS and HTML5 (Ciklum Kharkiv)
Prototyping app using JS and HTML5 (Ciklum Kharkiv)
 
Slides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testingSlides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testing
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009
 
Bringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C ProjectsBringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C Projects
 
JS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJSJS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJS
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
MVP Clean Architecture
MVP Clean  Architecture MVP Clean  Architecture
MVP Clean Architecture
 
Microsoft DevOps Solution - DevOps
Microsoft DevOps Solution - DevOps  Microsoft DevOps Solution - DevOps
Microsoft DevOps Solution - DevOps
 
Angularjs Basics
Angularjs BasicsAngularjs Basics
Angularjs Basics
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Delivery
 

More from Mohammad Azam (6)

Programmers Path to Content Creation
Programmers Path to Content CreationProgrammers Path to Content Creation
Programmers Path to Content Creation
 
Server Driven UI in iOS
Server Driven UI in iOSServer Driven UI in iOS
Server Driven UI in iOS
 
Flutter Presentation Houston TechFest 2019
Flutter Presentation Houston TechFest 2019Flutter Presentation Houston TechFest 2019
Flutter Presentation Houston TechFest 2019
 
iBeacons in Real Life
iBeacons in Real LifeiBeacons in Real Life
iBeacons in Real Life
 
Introduction towatchkit
Introduction towatchkitIntroduction towatchkit
Introduction towatchkit
 
Lessons learned3yearsappstore
Lessons learned3yearsappstoreLessons learned3yearsappstore
Lessons learned3yearsappstore
 

Lessons-Learned-SwiftUI.pptx