Widget's showing up completely blank on iOS 14 simulator

I've been following the part 1 tutorial until the point where they deploy the widgets to the simulator.

I noticed that my widget was completely blank.

Checked other widgets and noticed that the apple news widgets on the simulator is like this as well.

Heres the code:

Code Block Swift
//
//  EmojiRangerWidget.swift
//  EmojiRangerWidget
//
//  Created by Brent Mifsud on 2020-06-24.
//  Copyright © 2020 Apple. All rights reserved.
//
import WidgetKit
import SwiftUI
import Intents
struct Provider: IntentTimelineProvider {
    public func snapshot(for configuration: ConfigurationIntent, with context: Context, completion: @escaping (SimpleEntry) -> ()) {
let entry = SimpleEntry(date: Date(), character: .panda)
        completion(entry)
    }
    public func timeline(for configuration: ConfigurationIntent, with context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
var entries: [SimpleEntry] = [
SimpleEntry(date: Date(), character: .panda)
]
        // Generate a timeline consisting of five entries an hour apart, starting from the current date.
        let currentDate = Date()
        for hourOffset in 0 ..< 5 {
            let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
let entry = SimpleEntry(date: entryDate, character: .panda)
            entries.append(entry)
        }
        let timeline = Timeline(entries: entries, policy: .atEnd)
        completion(timeline)
    }
}
struct SimpleEntry: TimelineEntry {
    public let date: Date
let character: CharacterDetail
}
struct PlaceholderView : View {
    var body: some View {
        Text("Placeholder View")
    }
}
struct EmojiRangerWidgetEntryView : View {
    var entry: Provider.Entry
    var body: some View {
AvatarView(entry.character)
    }
}
@main
struct EmojiRangerWidget: Widget {
    private let kind: String = "EmojiRangerWidget"
    public var body: some WidgetConfiguration {
        IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider(), placeholder: PlaceholderView()) { entry in
            EmojiRangerWidgetEntryView(entry: entry)
        }
        .configurationDisplayName("Emoji Ranger Detail")
        .description("Keep track of your favorite emoji ranger.")
    }
}
struct EmojiRangerWidget_Previews: PreviewProvider {
static var previews: some View {
AvatarView(.panda)
.previewContext(WidgetPreviewContext(family: .systemSmall))
}
}




Replies

Some additional details: im using the iPhone 11 Pro max simulator
Hi,

Sorry that is happening. There are some known issues with IntentProvider widgets in the simulator. Please file a feedback with some more information and we can make sure you see when that is resolved.

To work around this: Try on a real device or in Xcode Previews.
I was getting a no intents error when this happened to me. The issue is that when you create the new Widget, you must make sure the intent configuration option is not selected. For me it was selected by default. So if you sent IntentConfiguration in your EmojiRangerWidget, then change it to StaticConfiguration. You will have to change other references to intents as well. If you don't feel comfortable with that, then start from a fresh version of Part 1 and when you add the new Widget file, just uncheck the intent configuration box. Then it will work up until the isPlaceholder(true) step at the end that is not currently available in Beta 1.
Had the same issue. I noticed the end example actually differs from Part 1 of the code-along, specifically it conforms to TimelineProvider instead of IntentTimelineProvider, and subsequently removing the use of Intent.

You can refer to Part 2 oof the example code, or the below.

Code Block
import WidgetKit
import SwiftUI
import Intents
struct Provider: TimelineProvider {
   
  public typealias Entry = SimpleEntry
  func snapshot(with context: Context, completion: @escaping (SimpleEntry) -> ()) {
    let entry = SimpleEntry(date: Date(), character: .panda)
    completion(entry)
  }
  func timeline(with context: Context, completion: @escaping (Timeline<SimpleEntry>) -> ()) {
    let entries: [SimpleEntry] = [SimpleEntry(date: Date(), character: .panda)]
    let timeline = Timeline(entries: entries, policy: .atEnd)
    completion(timeline)
  }
}
struct SimpleEntry: TimelineEntry {
  public let date: Date
  public let character: CharacterDetail
}
struct PlaceholderView : View {
  var body: some View {
    AvatarView(.panda)
  }
}
struct EmojiRangerWidgetEntryView : View {
  var entry: Provider.Entry
  var body: some View {
    AvatarView(entry.character)
     
  }
}
@main
struct EmojiRangerWidget: Widget {
  private let kind: String = "EmojiRangerWidget"
  public var body: some WidgetConfiguration {
    StaticConfiguration(kind: kind, provider: Provider(), placeholder: PlaceholderView()) { entry in
      EmojiRangerWidgetEntryView(entry: entry)
    }
    .configurationDisplayName("Ranger Detail")
    .description("See your favorite ranger.")
    .supportedFamilies([.systemSmall])
  }
}
struct EmojiRangerWidget_Previews: PreviewProvider {
  static var previews: some View {
    Group {
      AvatarView(.panda)
        .previewContext(WidgetPreviewContext(family: .systemSmall))
       
      PlaceholderView()
        .previewContext(WidgetPreviewContext(family: .systemSmall))
    }
  }
}


I have same issue, as I tested: IntentTimelineProvider always show blank on simulator, I need to use TimelineProvider.
Then in the near future, I will convert static type into intend type later.
Sadly, hope Apple will fix it soon.

My system info:
Mac Big Sur 11.0 Beta (20A4299v)
xCode Version 12.0 beta (12A6159)
iPhone 11 pro simulator

Oh, my final decision is keep using IntentTimelineProvider run on physical devices, run it on physical devices will avoid blank content.