Conclusion

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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.

For more on using UIKit in SwiftUI, see Interfacing with UIKit.

See forum comments
Download course materials from Github
Previous: Building a Coordinator Class Next: Quiz: Using UIKit Frameworks in SwiftUI