SlideShare une entreprise Scribd logo
1  sur  113
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

Contenu connexe

Tendances

Deep dive into swift UI
Deep dive into swift UIDeep dive into swift UI
Deep dive into swift UIOsamaGamal26
 
Swift UI - Declarative Programming [Pramati Technologies]
Swift UI - Declarative Programming [Pramati Technologies]Swift UI - Declarative Programming [Pramati Technologies]
Swift UI - Declarative Programming [Pramati Technologies]Pramati Technologies
 
How native is React Native? | React Native vs Native App Development
How native is React Native? | React Native vs Native App DevelopmentHow native is React Native? | React Native vs Native App Development
How native is React Native? | React Native vs Native App DevelopmentDevathon
 
Kotlin Jetpack Tutorial
Kotlin Jetpack TutorialKotlin Jetpack Tutorial
Kotlin Jetpack TutorialSimplilearn
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesomeAndrew Hull
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React NativeSambhu Lakshmanan
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react nativeDani Akash
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsPeter Friese
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlowAiste Stikliute
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfKnoldus Inc.
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentationBojan Golubović
 
Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015johannes_fiala
 
Connecting Connect with Spring Boot
Connecting Connect with Spring BootConnecting Connect with Spring Boot
Connecting Connect with Spring BootVincent Kok
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseChristian Melchior
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkMicha Kops
 
Unidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIUnidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIYusuke Kita
 

Tendances (20)

Deep dive into swift UI
Deep dive into swift UIDeep dive into swift UI
Deep dive into swift UI
 
React Native
React NativeReact Native
React Native
 
Swift UI - Declarative Programming [Pramati Technologies]
Swift UI - Declarative Programming [Pramati Technologies]Swift UI - Declarative Programming [Pramati Technologies]
Swift UI - Declarative Programming [Pramati Technologies]
 
React Native
React Native React Native
React Native
 
How native is React Native? | React Native vs Native App Development
How native is React Native? | React Native vs Native App DevelopmentHow native is React Native? | React Native vs Native App Development
How native is React Native? | React Native vs Native App Development
 
Async js
Async jsAsync js
Async js
 
Kotlin Jetpack Tutorial
Kotlin Jetpack TutorialKotlin Jetpack Tutorial
Kotlin Jetpack Tutorial
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 
Introduction to react native
Introduction to react nativeIntroduction to react native
Introduction to react native
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlow
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
 
Rest assured
Rest assuredRest assured
Rest assured
 
Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015Document your rest api using swagger - Devoxx 2015
Document your rest api using swagger - Devoxx 2015
 
Connecting Connect with Spring Boot
Connecting Connect with Spring BootConnecting Connect with Spring Boot
Connecting Connect with Spring Boot
 
Coroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in PractiseCoroutines for Kotlin Multiplatform in Practise
Coroutines for Kotlin Multiplatform in Practise
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured framework
 
Unidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIUnidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUI
 

Similaire à Lessons-Learned-SwiftUI.pptx

Visual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonVisual Automation Framework via Screenshot Comparison
Visual Automation Framework via Screenshot ComparisonMek Srunyu Stittri
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
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-latestOnur Baskirt
 
"Universal programming recipes", Kateryna Trofimenko
"Universal programming recipes", Kateryna Trofimenko"Universal programming recipes", Kateryna Trofimenko
"Universal programming recipes", Kateryna TrofimenkoBadoo Development
 
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 TechnologyBadoo
 
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 FrameworksKunal Ashar
 
Building databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsBuilding databound JavaScript apps with Knockoutjs
Building databound JavaScript apps with KnockoutjsNish Anil
 
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
 
MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009MVVM Design Pattern NDC2009
MVVM Design Pattern NDC2009Jonas Follesø
 
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 ProjectsRené Cacheaux
 
JS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJSJS FAST Prototyping with AngularJS & RequireJS
JS FAST Prototyping with AngularJS & RequireJSYuriy Silvestrov
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Microsoft DevOps Solution - DevOps
Microsoft DevOps Solution - DevOps  Microsoft DevOps Solution - DevOps
Microsoft DevOps Solution - DevOps Chetan Gordhan
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Deliverymasoodjan
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVMBoulos Dib
 

Similaire à 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)
 
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
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
 

Plus de Mohammad Azam

Programmers Path to Content Creation
Programmers Path to Content CreationProgrammers Path to Content Creation
Programmers Path to Content CreationMohammad Azam
 
Server Driven UI in iOS
Server Driven UI in iOSServer Driven UI in iOS
Server Driven UI in iOSMohammad Azam
 
Flutter Presentation Houston TechFest 2019
Flutter Presentation Houston TechFest 2019Flutter Presentation Houston TechFest 2019
Flutter Presentation Houston TechFest 2019Mohammad Azam
 
iBeacons in Real Life
iBeacons in Real LifeiBeacons in Real Life
iBeacons in Real LifeMohammad Azam
 
Introduction towatchkit
Introduction towatchkitIntroduction towatchkit
Introduction towatchkitMohammad Azam
 
Lessons learned3yearsappstore
Lessons learned3yearsappstoreLessons learned3yearsappstore
Lessons learned3yearsappstoreMohammad Azam
 

Plus de 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