8

I work on an iOS app supporting iOS 15 and above, with a widget supporting iOS 16 and above.

The widget currently does not load on iOS 17 beta, for users it's just an empty box, both during snapshot preview while choosing the widget size, and after placing it on the home screen.

When building it from Xcode, I get the following error:

-[INIntent _initWithIdentifier:backingStore:schema:error:] Missing backing store for Intent: {xxx-xxx-xxx some ID} (N/A - N/A)

The app uses a custom Intent to allow some settings on the widget. The widget and app share data through an App Group to avoid duplication of network requests.

I could not find any information on this error on SO, nor on Apple beta release notes. Is anybody experiencing this as well?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
BrickDeLait
  • 117
  • 9
  • I'm having similar issues. On top of that it states "No AppIntent in timeline(for:with)". Also my Widgets only install after a reboot of the device, after a while they just disappear from the list. Lastly, the configuration using AppIntents is messed up too and only works once before it won't show any results in my custom types converted to AppEntities. At least installing the App Store version on my iOS 17 devices lets all widgets work without problems. Maybe there are still some heavy bugs in XCode 15.. Anyway I'll opt in here to see if you'll be able to fix the problem. – optz Jul 23 '23 at 16:30
  • I realise that I indeed need to do convert my custom Intent to AppIntents. I tried it and it seems that everything was converted properly, but the widget still is blank. I'll keep you updated on the progress. – BrickDeLait Jul 24 '23 at 08:26

2 Answers2

2

Have you tried to add

let configuration: ConfigurationAppIntent in the TimeLine Entry?

Example:

struct SimpleEntry: TimelineEntry {
     let date: Date
     let configuration: ConfigurationAppIntent
     let character: CharacterDetail
 }


func placeholder(in context: Context) -> SimpleEntry {
    SimpleEntry(date: Date(), configuration: ConfigurationAppIntent(), character: .panda)
}

func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry {
    SimpleEntry(date: Date(), configuration: ConfigurationAppIntent(), character: .panda)
}

This code is generated automatically, and basically it's the view that you see when the widget turns or spins to the other side

import WidgetKit
import AppIntents

struct ConfigurationAppIntent: WidgetConfigurationIntent {
    static var title: LocalizedStringResource = "Configuration"
    static var description = IntentDescription("This is an example widget.")

    // An example configurable parameter.
    @Parameter(title: "Favorite Emoji", default: "")
    var favoriteEmoji: String
}

This worked for me using the example EmojiRangers

Sophy Swicz
  • 1,307
  • 11
  • 21
  • Hello, in which library `ConfigurationAppIntent` is located? I tried importing `AppIntents` but that did not work. Was this solution suggested somewhere in a WWDC talk that I could take a look at? – BrickDeLait Jul 24 '23 at 08:24
  • Ups you're right, this is generated automatically in Xcode 15 beta, so I thought you would have it. I will edit my answer – Sophy Swicz Jul 24 '23 at 18:28
  • Thanks for your suggestion, I just tried it but unfortunately it did not solve the problem :/ – BrickDeLait Jul 31 '23 at 06:44
  • @BrickDeLait try again with the latest beta (Beta 5) – Sophy Swicz Aug 03 '23 at 17:15
  • I updated to beta 5 like you suggested, I no longer have the crash described in my issue. Now I think my problem is related to this issue with the background API: https://stackoverflow.com/questions/76595240/widget-on-ios-17-beta-device-adopt-containerbackground-api?rq=2 I'll mark your answer as accepted as it was the most helpful at finding the solution. – BrickDeLait Aug 07 '23 at 10:33
  • Oh I see, I didn't mention the background API because I thought at first it was related with the TimeLineEntry / AppIntent methods only which was my issue at first, but I've also had the background missing and added it immediately. For me almost all warnings disappeared in the new beta 5. But I was using the emoji rangers example provided by Apple last year. – Sophy Swicz Aug 08 '23 at 09:19
  • Would you mind sharing? Facing similar issue. Maybe your explorations could help. – dziobaczy Aug 17 '23 at 22:51
1

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
            }
        }
    }
optz
  • 391
  • 1
  • 10
  • Thanks for your answer. I am not sure that this is fully related to the issue I am having: I only use a custom intent for customizing the widget, so I do not use the `EntityQuery` anywhere in my app... But I will give a try to your idea in the `IntentTimelineProvider` struct that is responsible for creating the widget timeline. – BrickDeLait Jul 31 '23 at 06:40
  • did you solve the issue you described here? https://stackoverflow.com/questions/76678652/widgetkit-widgets-not-showing-up-on-ios-17 – BrickDeLait Jul 31 '23 at 06:46
  • Yes, I was the one who was asking the question before I found yours. I'll mark it as resolved there. I am not using EntityQueries anywhere else either, just used the xcode migration tool to translate my SiriKit Intent to AppIntents. – optz Aug 01 '23 at 07:27
  • Ah ok I see. I'll try that and update this with my findings. – BrickDeLait Aug 01 '23 at 11:00
  • The problem with that approach is that I need to start using an AppEntity and AppIntent, migrate everything and in my Widget struct body start using `AppIntentConfiguration` instead of `IntentConfiguration`. But that is iOS 17 only and I want to support iOS 16. Is that the approach you took after migrating? With an if #available statement and duplicating some code to support both? – BrickDeLait Aug 07 '23 at 08:25
  • Updating to a latest version of Xcode beta provided better logs that suggest its a different issue. Thanks for your help! – BrickDeLait Aug 07 '23 at 10:34
  • 1
    Yes, that’s what I did. It’s working for me now too but I’ll try again with the new Xcode build to see why it failed before migrating to AppIntents. Thanks for the update! – optz Aug 25 '23 at 06:26