Native interop with Jetpack Compose and SwiftUI handlers #29199
Replies: 4 comments 3 replies
-
I am also interested in this question. As you have laid out, it certainly does appear that Jetpack Compose and SwiftUI are very much the direction of travel. Achieving some form of interop with these would seem to be essential to securing a long-term future for MAUI, at least so long as the rendering model continues to be to target native controls on each platform. Whilst the UIKit and Views approaches are not likely to disappear in the short term, it's clear the latest platform features are going to be focussed around the new frameworks.
I had the same question in mind, and I have tried to find the latest public statements on this topic. My understanding is that in the case of SwiftUI, there is work to be done by the .NET runtime team as a pre-requisite, tracked here: I'm less clear on what is required for Compose support within MAUI, and I could not find a work item anywhere regarding this, but did find some related discussion on the below pull reuqest, where it sounds like the dotnet android tooling would have to perform some functions currently performed by a kotlin compiler plugin. Perhaps @jonathanpeppers might be willing to let us know if anything along these lines is or could be planned?
Whilst it's perhaps not a DSL at the level of the runtime, we've loved using the .NET MAUI Markup Community Toolkit in favour of XAML for a few years now, with great results. It does allow a declarative paradigm, similar to SwiftUI and Compose, to be used today. |
Beta Was this translation helpful? Give feedback.
-
Regarding the original comment:
I'm not sure that is true, this would mean Android deprecates hundreds, (thousands?) of APIs that have been available since Android API 1. I just don't think they can ever break the entire ecosystem like that. |
Beta Was this translation helpful? Give feedback.
-
That is a very interesting observation @waelbouchnak and I agree with @markmccaigue that Android is focusing on Jetpack Compose. Even though as Jonathan puts it, these changes might not be right around the corner yet, but I think it is worthy to have this fact in mind that one day Google will focus so much on Jetpack Compose components that effectively renders the Views obsolete, like the move they had done with Camera, Camera2 and CameraX. It will not happen over night, but it will happen. Specially for Google that is even in their documentation shifting away the developers attention to Compose. Probably a time will come that this shift will take place gradually as MAUI team will favor an Android Jetpack Compose component to their old counterparts (probably due to better behavior/features) and migration happen gradually, same for SwiftUI. I guess we should see how things evolve, and if Microsoft decides to pay more attention to NET MAUI or not. |
Beta Was this translation helpful? Give feedback.
-
For what it's worth, you can embed SwiftUI components into your MAUI app (with the use of a UIHostingController). I think you could achieve something similar with Java, although I haven't tested that personally: https://stackoverflow.com/questions/67423907/possible-to-use-lay-out-a-compose-view-in-an-activity-written-in-java Might not work for all cases or wants but definitely gets past the "this is only available in SwiftUI" problem for us at least. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
💡 Idea Summary
With the ongoing deprecation of Android’s XML-based Views and Apple’s increasing shift toward SwiftUI, it’s worth considering a future direction where .NET MAUI’s handlers system could directly integrate with Jetpack Compose and SwiftUI as the native render targets, instead of relying on legacy UI frameworks (ViewGroup/UIViews/etc).
🤔 Why This Matters
Jetpack Compose is now the official recommended way to build Android UIs.
SwiftUI is rapidly replacing UIKit and storyboards on Apple platforms.
MAUI currently renders to legacy view systems, which may be deprecated or unsupported in the coming years.
Modern UI trends favor declarative and composable UI DSLs, which are currently missing in MAUI unless we manually implement a C#-only abstraction.
🧱 Proposed Approach
Extend the MAUI handler architecture to optionally target:
Jetpack Compose components (e.g., Text, Column, Row, etc.)
SwiftUI views (Text, VStack, Button, etc.)
Create bridges or rendering backends that allow MAUI to map controls like Label, Button, VerticalStackLayout to their modern native equivalents:
Example:
new Label { Text = "Hello" } // maps to -> Text("Hello") in Compose or SwiftUI based on platform
No reliance on XML or Storyboards, enabling full C#-driven app logic with modern native performance and look.
👉 QUESTION
What is the long-term plan for MAUI once native Android Views and Storyboards are no longer supported?
Will handlers eventually be mapped to Jetpack Compose/SwiftUI?
Will Microsoft introduce a C#-native declarative UI DSL similar to Compose/SwiftUI?
Beta Was this translation helpful? Give feedback.
All reactions