UIKit in visionOS

The default framework of visionOS is SwiftUI, but it can also be combined with UIKit in SwiftUI, and Apple has also released video documents and other content for this purpose. But what I want to know is that SwiftUI is much simpler than UIKit, but why does Apple recommend developers to combine with UIKit in SwiftUI? I also want to know what are the advantages of SwiftUI and UIKit in visionOS?

I hope you can reply to my two questions. Thank you!

Answered by Vision Pro Engineer in 766259022

Hi @lijiaxu ,

Apple recommends SwiftUI as the way to create visionOS apps. The reason you have seen WWDC videos on using UIKit and SwiftUI together to create visionOS apps is because we have so many developers who already have apps using UIKit and want to be able to use that same code for their visionOS app. Since visionOS works the best with SwiftUI, these videos are meant to help them put together code that runs on visionOS even if the app is built with UIKit.

If you are creating a new app for visionOS, I recommend you use just SwiftUI. You will get native behavior this way without having to do any extra customization on your part.

Accepted Answer

Hi @lijiaxu ,

Apple recommends SwiftUI as the way to create visionOS apps. The reason you have seen WWDC videos on using UIKit and SwiftUI together to create visionOS apps is because we have so many developers who already have apps using UIKit and want to be able to use that same code for their visionOS app. Since visionOS works the best with SwiftUI, these videos are meant to help them put together code that runs on visionOS even if the app is built with UIKit.

If you are creating a new app for visionOS, I recommend you use just SwiftUI. You will get native behavior this way without having to do any extra customization on your part.

UIKit in visionOS
 
 
Q