23

Is it possible to create Xcode widget in Xcode 12 but without the use of SwiftUI and instead use XIB files to construct the Widget UI?

Vlad
  • 5,727
  • 3
  • 38
  • 59

2 Answers2

27

Widget protocol is only available in SwiftUI framework, so you can only create widgets using SwiftUI.

https://developer.apple.com/documentation/swiftui/widget

Update

You can't use UIKit views wrapped in UIViewRepresentable within SwiftUI for Widgets, It will appear blank.

https://developer.apple.com/forums/thread/653471

Bilal
  • 18,478
  • 8
  • 57
  • 72
  • 1
    According to my tests UIKit views wrapped in UIViewRepresentable will not work in widgets. This answer from an Apple frameworks engineer suggest it as well: https://developer.apple.com/forums/thread/653471 – florieger Jul 29 '20 at 10:01
10

No, due to performance and battery life concerns, WidgetKit only works with SwiftUI.

https://developer.apple.com/documentation/widgetkit

You configure the widget with a timeline provider, and use SwiftUI views to display the widget’s content. The timeline provider tells WidgetKit when to update your widget’s content.