I developed an app with 10 widgets but some iPhone, iPad or macOS users report that my widgets or the "App Name" don't appear in the widgets list when they tried to add the widgets of my app. There's no way I can replicate the problem, but the number of the users that report this issue is growing up every day.
It’s not clear if the problem is caused by the iPhone model, a crash on the widget preview or other factors.
My widgets previews are built reading static data, so this data is the same in every conditions.
I suggest my users to do the following steps:
Start the app and go to check again if "App name" appears among widget List Close every app and restart the device; then start the app and go to check again if "App name" appears among widget List Temporarily change system language and turn on Bold Text and go to check again if "App Name" appears among widget List Uninstall and reinstall the app, start the app and go to check again if "App Name" appears among widget List But all users who have tried these steps say that the app still does not appear in the list of widgets.
The following code is the one I use inside the main widgets swift file called TodayWidgetExtension:
import WidgetKit
import SwiftUI
struct PlaceholderView : View {
var body: some View {
Text("loading")
}
}
//MARK: - Main widget bundle configuration
@main
struct WidgetBundle: WidgetBundle {
@WidgetBundleBuilder
var body: some Widget {
//MARK: - 1
Widget1Large()
Widget1Medium()
Widget1Small()
if #available(iOSApplicationExtension 16.0, *) {
Widget1Accessory()
}
//MARK: - 2
Widget2Large()
//MARK: - 3
#if !targetEnvironment(macCatalyst)
Widget3Medium()
#endif
//MARK: - 4
Widget4Large()
//MARK: - 5
Widget5Medium()
//MARK: - 6
Widget6Large()
Widget6Medium()
}
}
struct todaywidgetextension_Previews: PreviewProvider {
static var previews: some View {
PlaceholderView()
.previewContext(WidgetPreviewContext(family: .systemSmall))
}
}
The only thing that I've noticed debugging the widgets extension is that, even if I don't add any of them to my iPhone screen, Xcode tells me that widgets occupied 20mb of memory (the limit for widgets is 30mb).
I tried removing all the widgets from the above code leaving only one (Widget1Small for example), but Xcode continues to tell me that 20mb of memory are still occupied.
I hope that someone can help me.
Thank you.