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?
Asked
Active
Viewed 6,119 times
2 Answers
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.

Bilal
- 18,478
- 8
- 57
- 72
-
1According 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.

Charlie Welsh
- 101
- 3
-
3
-
2Nonsense. Apple just trying to force us to use swiftUI even if we don't want. – user1105951 Feb 27 '22 at 16:34