When I tried submitting with Beta 2 I got an ITMS error saying I'm uploading from an incompatible version of Xcode. When I updated to Beta 3, the error went away, but now I'm running into these issues.
Post
Replies
Boosts
Views
Activity
I just tried Xcode beta 4 and the issue is NOT resolved.
Yeah it's pretty annoying. I'm trying to get a new build of my app up on TestFlight but I'm currently stuck.
After updating to iOS Beta 4, it seems the widgets are now appearing again (at least with the build I have with dead-code stripping and unchecking including the iOS Bitcode)
As an update, this issue seems to only appear on device.
In the simulator of iOS 14, it works fine.
Further information
This only appears on actual devices, in the simulator, the issue does not appear.
The issue only appears with projects created with the SwiftUI App Life Cycle. The issue does not appear in projects with the UI Kit App Delegate Life Cycle projects.
I submitted a feedback: FB8285799
You can recreate this issue by creating a new project, choosing SwiftUI App from the Life Cycle dropdown, and replacing your ContentView with the following code.
If anyone has any thoughts on a workaround I'd appreciate it!
import SwiftUI
struct ContentView: View {
		var body: some View {
TabView {
AgendaView()
.tabItem {
Image(systemName: "list.bullet")
Text("Agenda")
}
HealthView()
.tabItem {
Image(systemName: "heart")
Text("Health")
}
SettingsView()
.tabItem {
Image(systemName: "gear")
Text("Settings")
}
}
		}
}
struct AgendaView: View {
var body: some View {
VStack {
Text("Hello, AgendaView!")
}.onAppear{
print("AgendaView.onAppear")
}.onDisappear(){
print("AgendaView.onDisappear")
}
}
}
struct HealthView: View {
var body: some View {
VStack {
Text("Hello, HealthView!")
}.onAppear{
print("HealthView.onAppear")
}.onDisappear(){
print("HealthView.onDisappear")
}
}
}
struct SettingsView: View {
var body: some View {
VStack {
Text("Hello, SettingsView!")
}.onAppear{
print("SettingsView.onAppear")
}.onDisappear(){
print("SettingsView.onDisappear")
}
}
}
I keep getting the same error. It seems that maybe 1 in 5 times it will work.
I managed to solve it in my case. I had recently configured my app to run on Mac as well as a test. To do that, I had to add a Runpath Search Path @executable_path/../Frameworks in the Widget Extension's Build Settings.
Removing that resolved the issue.
When I actually add the widget to the homescreen, the widget displays properly.
From the documentation, snapshot appears to be what is used for the Widget Gallery view:
WidgetKit calls snapshot(for:with:completion:) when the widget appears in transient situations. If context.isPreview is true, the widget appears in the widget gallery. Regardless, I am passing entries in the timeline - below is my code. I'm only providing one timeline entry since I want to refresh the data every 15 minute increments. (This is an agenda widget, so I want to load any new calendar events, etc). I set the entry date for the 15 minute mark so it refreshes roughly every 15 minutes.
I also tried passing two entries: one for Date(), and one with the Refresh date below, and I still see the same issue.
var entries: [SimpleEntry] = []
let refreshDate = DateHelper.shared.nextWidgetRefreshDate(frequency: 15)
let agendaViewModel = AgendaViewModel()
agendaViewModel.getData(hidePastEvents: true) {
let agendaItemsByDate = Array(agendaViewModel.agendaItemsByDate.prefix(2))
let entry = SimpleEntry(date: refreshDate, agendaItemsByDate: agendaItemsByDate)
entries.append(entry)
let timeline = Timeline(entries: entries, policy: .atEnd)
completion(timeline)
}
The above solution by jcgoforth doesn't seem to work for me. Even inside the view, the \.widgetFamily is returning .systemMedium when the view is large.
Ok, I figured it out. The method is getSnapshot, not snapshot
I'm surprised it didn't give me a build error.
For the record, I can confirm that getSnapshot is what is used to show a snapshot of your widget in the Widget Gallery, not getTimeline.
I definitely see a use case for it and submitted a feedback! In my case, I have a HealthKit-based widget that isn't functional on iPads, so I'd like to only expose it to iPhone users.
Feedback ID: FB8454119