Which UI framework will be better for developing user interface, UIKit or SwiftUI [closed]

Please help me understand what will be better for the complex app for the Apple platform I read a few articles about UIKit vs SwiftUI and quoted one of the articles <You can choose UIKit if you want maximum control over how your app looks. > this phrase is a little confused me.

I know about widgets, rendering ideas, minimum iOS version, live preview, and speed of development, I am not worried about this stuff.

This question is easy to get an answer to but with the complex app it's a big problem, I will try to focus on key points for a more accurate representation of the problem.

My requirements for the app are:

  • Future supporting, ideally one app for iOS and Mac OS platform( exclude audience that prefers Mac platform for work, UI should be different).
  • Maximum UI control, I mean animation and interaction, the application will be huge.
  • Classic UI like in Apple News, Podcasts, App Store.
  • Complex architecture like VIP.

I don’t have enough experience with SwiftUI, but can say that can do all that I want using UIKit, my one complex example with SwiftUI and UIKit was 3D Carousel, and I can say that this is easy using SwiftUI, but it was only one complex stuff which I tried and that’s it

In short form, my question is: can I do any interaction and most of the animation using SwiftUI, because I hope in another interaction like DB, etc it will not be a problem.

You will hear various opinions on this. Some explaining that SwiftUI is the way to go, other that UIKit is so much more robust and flexible.

For WatchOS, TVOS, It is probably now a very good choice.

But for iOS or MacOS apps, my personal choice is still clearly UIKit. Even though you can usually achieve a lot of things with SwiftUI, I find it requires convoluted workaround if you need a lot of custom features. Maybe things will change in a few years ?

Yes, you are right, It's a little confusing question to me especially because I read many opinions, thank you for your question, I share your opinion about UIKit. I know that in my case I not planning to use a lot of custom features, and I guess that SwiftUI is not bad, but I am not sure about features like gestures, PIP, and sometimes a few windows or perhaps something else, etc., will be continue closed. I don't know how it is work, but I found info that it is possible.

I like swiftUI's declarative syntax, but UIKit and AppKit is really much more powerful. Anyway, I like to create a swiftUI app and then add whatever I need in NS/UIViewRepresentable.

@makabaka1880 thank you for your opinion, please share your experience with NS/UIViewRepresentable, it's hard to add something, and how does it affect code readability?

It is really simple to add UIViewRepresentable to embed UIKit code.

Here is for instance how you would add a WebView:

struct WebView: UIViewRepresentable{
   
  let request : URLRequest
   
  private var webView: WKWebView?
   
  init (request: URLRequest){
     
    self.webView = WKWebView()
    self.request = request
  }
   
  func makeUIView(context: Context) -> WKWebView{
    return webView!
  }
   
  func updateUIView(_ uiView: WKWebView, context: Context) {
    uiView.load(request)
  }
    
  func goBack(){
    webView?.goBack()
  }
   
   
  func goForward(){
    webView?.goForward()
  }
   
  func goHome(){
    webView?.load(request)
  }
   
  func refresh(){
    webView?.reload()
  }
}

@Claude31 thank you for the example, really not hard, and looks good. I have to continue to read info about SwiftUI, I planing use it for big product apps and have read a lot of articles, and also find two examples that worry me about why don't need to use SwiftUI in B2B if you have experience with B2B SwiftUI app what you can say about that?

  1. https://prograils.com/swift-ui-b2b-app-2022
  2. https://stevenpcurtis.medium.com/swiftui-still-isnt-production-ready-39c6ee60f391

I am interested in your opinion

Which UI framework will be better for developing user interface, UIKit or SwiftUI [closed]
 
 
Q