2

I have a set of Widgets that work flawlessly on Xcode 14 and iOS 16, both on Simulator and Device. With Xcode 15 beta (4), these widgets simply don't show up anymore on the iOS 17 Simulator, and I feel like I've tried everything.

Building with the new Xcode 15 beta on any iOS 16 or 15 simulator works fine and the widgets are available. They're just gone on iOS 17.0.

When I add a new widget extension it shows up immediately on the iOS 17 simulator. I've compared every single line on the Build Settings but couldn't find any difference there.

I have also updated the SiriKit Intent to an AppIntent with no success.

Anyone experiencing the same issue? Or any clue on what I could have missed?

optz
  • 391
  • 1
  • 10
  • Hi @optz having the same issue. Image for for icon are showing a cross instead of actual image. Did you managed to find a solution? – TT_TT Jul 18 '23 at 06:21
  • I’m still looking around but I have a suspicion about a memory issue. I found that adding an empty widget before all others lets me see my widgets again. What I suspect is that on iOS 17 somehow there’s more memory allocated compared to iOS 16 which then exceeds the limit. If that is the first widget in the bundle it simply doesn’t show them as available anymore. Not sure about it yet though, I still need to test if this is actually the reason. – optz Jul 19 '23 at 08:29
  • I believe Widgets are generally pretty buggy on iOS 17. I created a completely fresh project with zero custom code and launched the widget which would sometimes fail to show as well. When it appears, the memory is at 24 MB. That leaves us a real 6 MB of memory for the entire widget until it exceeds the limit. Generally, deleting the app and then closing the Simulator gives me the best chance to have the widget show up when running the app. I then have one shot at editing it before it fails to work again. Same between the test widget and my actual ones. – optz Jul 21 '23 at 09:42
  • When you write "don't show up", you mean you cannot even find them in the list of widgets to add, or that they are there, but blank? – BrickDeLait Aug 07 '23 at 08:49
  • They weren’t even displayed, in fact the whole app was missing in the widget list – optz Aug 25 '23 at 06:28

1 Answers1

0

I could resolve this by making sure the intent is running on the main thread. With iOS 17 it seems the intent code can now run directly in the app and on the widget extension.

For me the extension seems to have crashed because it was running the code in the app instead of the extension. Some parts of my code are a bit old and need to run on the main thread. The EntityQuery is running on a background thread though so I changed this and it's working again in my case.

struct DataAppEntityQuery: EntityQuery {
        func entities(for identifiers: [DataAppEntity.ID]) async throws -> [DataAppEntity] {
            let data = await retrieveData().filter { identifiers.contains($0.id) }
            return data
        }

        func suggestedEntities() async throws -> [DataAppEntity] {
            return await retrieveData()
        }
        
        func defaultResult() async -> DataAppEntity? {
            try? await suggestedEntities().first
        }
        
        
        func retrieveData() async -> [DataAppEntity] {
            //code that needs to run on the main thread in my case            

            await MainActor.run {
                //....
                return data
            }
        }
    }

Also it seems that in my case the simulator uses way more memory than the real device. This makes testing on the simulator a bit useless because it runs out of memory and fails the widget where the device only uses some 13 MB.

optz
  • 391
  • 1
  • 10