In this lesson, you learned how to integrate SwiftUI with existing UIKit views using MapKit. You built views using Representable-derived protocols to integrate SwiftUI with other Apple frameworks, which requires implementing two required methods in these protocols to create the view and do setup work. You created a Coordinator class that gave you a way to connect data in SwiftUI views with a view from previous frameworks. You can use this to manage delegates and related patterns. You instantiated the Coordinator in your SwiftUI view and placed other framework code in the Coordinator class.
Now, you can:
Describe the process of integrating SwiftUI views with UIKit components.
Demonstrate the use of UIViewRepresentable and coordinator classes to include UIKit frameworks in SwiftUI projects.
You should always ensure that you need to integrate UIKit into a SwiftUI project. With new apps, creating a new SwiftUI view instead of reusing an old UIKit approach might be a better use of your time. That said, integrating UIKit with SwiftUI can be a vital part of migrating legacy apps, eliminating the need to rewrite an entire app in one revision. Integrating the two also helps in cases where the SwiftUI equivalent of a UIKit view hasn’t caught up in functionality and features.
Previous: Building a Coordinator Class
Next: Quiz: Using UIKit Frameworks in SwiftUI
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.