Post

Replies

Boosts

Views

Activity

iOS SwiftUI WidgetKit: My widgets don’t show up in the ‘Add Widgets’ section
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.
1
0
745
Jan ’23
SwiftUI: Achieving Apple Notes App Smooth Text Editing Performance on iOS
I'm trying to build a high-performance text editor similar to the one found in the Apple Notes app. To eliminate uncertainties, I've created a SwiftUI app from scratch and added only the TextEditor view, nothing else. struct ContentView: View { @State private var text = "" var body: some View { TextEditor(text: $text) .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity) } } I've inserted a string with 347,023 characters, and text editing is very sluggish, slow, and text selection is even slower. The same string in the Apple Notes app exhibits smooth text editing and selection. I've also tried using UIKit with UITextView, but I'm experiencing the same performance drop. How can I achieve the same level of smooth text editing and performance as the Apple Notes app? I noticed that the following example is very smooth but you can't edit the text: https://developer.apple.com/documentation/uikit/textkit/using_textkit_2_to_interact_with_text Could you provide a basic example to start with for creating a highly performant text editor on iOS? Thank you.
0
0
802
Sep ’23