Magic of SwiftUI

Magic of SwiftUI

With the new iOS 13, SwiftUI has been one of the best feature offered by Apple. This talk will be a kick start to the new features SwiftUI has to offer to ease out the development process. The declarative and bindable nature would be the main focus here.

Speaker: Akanksha Sharma

Presented at Swift Mumbai Chapter 9 Meetup hosted by Dream11


Swift India

June 22, 2019


  1. Magic of SwiftUI By- Akanksha Sharma

  2. • Introduction to SwiftUI • What new in Swift UI?

    • Basic elements of SwiftUI • Is it Bye Bye Storyboards forever? • Scaling your app with SwiftUI • Time for some live coding
  3. AppKit - Construct and manage a graphical, event-driven Swift -

    Build apps using a powerful open language UIKit - Construct and manage a graphical, event-driven user interface Metal - Render advanced 3D graphics Foundation - Access essential data types, collections, and operating-system services Core Data - Persist or cache data Vision - Apply computer vision algorithms Core Animation - Render, compose, and animate visual elements. How Apple defines its frameworks
  4. 1 How has Apple defined Swift UI

  5. Declare When you don’t or maybe don’t want to care

    about how the task is done, you just DECLARE it to be done by someone Here SwiftUI is doing the how part of the task, we just have to care about What has to be done.
  6. Example of text label & color in UI Kit textLabel.text

    = "Hello World" textLabel.textColor = textLabel.font = UIFont.systemFont(ofSize: 17.0) Example of text label & color in SwiftUI Text("Hello World") .font(.title) .color(.green)
  7. 1 2

  8. • Merge issues with large storyboards • Interface Builder has

    no idea about how are code is working • UITableViews/CollectionViews or creating a view controller from storyboards or triggering segues, strings are used to name them These problems exist because IB and Swift are very separate things. This isn’t a huge surprise – not only does Interface Builder date from way before the original Mac OS X was a thing, but it’s also very much designed around the way Objective-C works User Interface
  9. 1 3 2

  10. Behavior State and Data Flow Control and respond to the

    flow of data and changes within your app’s models. Gestures Define interactions from taps, clicks, and swipes to fine-grained gestures.
  11. 1 3 2 4

  12. Multiple Platform Support • SwiftUI runs on iOS 13, macOS

    10.15, tvOS 13, and watchOS 6, or any future later versions of those platforms • The official line seems to be that SwiftUI is not a multi-platform framework, but is instead a framework for creating apps on multiple platforms. • Apple isn’t saying that you can use identical SwiftUI code on every platform
  13. Basic SwiftUI Project

  14. None
  15. None
  16. • ContentView - struct that implements View Protocol • Body

    - protocol conformance Variable • some View - return type of body which id of Opaque Type • Text("Hello World") - A label • ContentView_Previews -
  17. • UITableView : List • UICollectionView : No SwiftUI equivalent

    • UILabel : Text • UITextField : TextField • UITextField with isSecureTextEntry set to true : SecureField • UITextView : No SwiftUI equivalent • UISwitch : Toggle • UISlider : Slider • UIButton : Button • UINavigationController : NavigationView • UIAlertController with style .alert : Alert • UIAlertController with style .actionSheet : ActionSheet • UIStackView with horizontal axis : HStack • UIStackView with vertical axis : VStack • UIImageView : Image • UISegmentedControl : SegmentedControl • UIStepper : Stepper • UIDatePicker : DatePicker • NSAttributedString : Incompatible with SwiftUI; use Text instead.
  18. Let’s start some coding

  19. Thank You!!