How can TCA works compatible with ObjC? #1502
Replies: 2 comments 2 replies
-
Hi @alexlee002, TCA is a pure Swift library and so pretty much none of it is accessible from Objective-C. You could make Objective-C friendly wrappers for each of your TCA features (e.g. state, store, etc.), but it would be a huge amount of boilerplate, and probably not worth it. |
Beta Was this translation helpful? Give feedback.
-
One approach is to migrate the top-level of your application to use the new SwiftUI lifecycle, then present and orchestrate your existing objective-c / UIKit content by wrapping the top level view controller in UIViewcontrollerRepresentable. From there, you can incrementally update existing Swift features to use TCA state, start creating new features with SwiftUI and TCA, etc. For example, in one app, we had a top-level Obj-C custom view controller container that presented each main section's UI. We wrapped that in UIViewcontrollerRepresentable to provided a declarative interface for switching sections, etc. New features had child states that were pulled back from the new top-level state. Eventually, you can replace existing Obj-C sections of your app to complete the process. You might need to do this sooner, than later, if you need to show Obj-C / UIKit views in SwiftUI TCA sections of your app. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to import TCA into my project using UIKit, most of the code of my project is still using ObjC, the rest are using Swift.
How can TCA works compatible with ObjC? Thanks a lot!
Beta Was this translation helpful? Give feedback.
All reactions