This is part of the "iOS User Interfaces with UIKit" learning path. View Path

Integrating UIKit & SwiftUI

Dec 22 2020 · Video Course (25 mins) · Beginner

Learn how to integrate SwiftUI views into your UIKit apps and view hierarchies, and how to host UIKit views and view controllers in SwiftUI. Coordinate data flow from SwiftUI to UIKit and back again!

5/5 2 Ratings

Version

  • Swift 5.3, iOS 14, Xcode 12

Part 1

An easy way to start using SwiftUI is to add some to your existing UIKit apps! Replace a UIViewController with a SwiftUI view in the storyboard, and manage data flow between SwiftUI and the rest of the app.

1

You don't have to replace entire view controllers to get started with SwiftUI. You can embed SwiftUI views right into your view hierarchy from the storyboard with the help of @IBSegueAction.

2

If UIKit has a view or control that you need in your SwiftUI app, you can integrate it with UIViewRepresentable.

3

SwiftUI doesn't have a native photo picker, so you'll need UIKit's help to pick photos from your app. Learn how to use the new PHPicker in your SwiftUI apps.

4

SwiftUI doesn't make much use of the delegate pattern, but it's required for many UIKit controls like the PHPicker. Use a coordinator to add the delegates you need to host UIKit views.

5

The coordinator can help you out with more than delegates! You can also use it to implement target action for UIKit controls in SwiftUI.

6

Who is this for?

This course finishes up our iOS User Interfaces with UIKit learning path. It is intended for developers with some experience building iOS apps with UIKit and SwiftUI, as you'll be using both in every episode.

Covered concepts

  • UIHostingController
  • IBSegueAction
  • UIViewRepresentable
  • UIViewControllerRepresentable
  • SwiftUI Coordinator

Contributors

Comments