This is a critical bug with Document-Based Apps (SwiftData). If you download the WWDC 2023 sample code for"Building a document-based app using SwiftData" , open it in Xcode 16.1, and run it on an iOS 18+ simulator, you'll encounter a major issue. When you exit a document and reopen it, you'll find that the changes you just made were not saved.
iOS 18 has effectively rendered last year's WWDC 2023 sample code obsolete!
Has anyone managed to successfully save data in a Document-Based App using SwiftData?
Post
Replies
Boosts
Views
Activity
Trends page unavailable
import SwiftUI
import TipKit
@main
struct TipKit_WithPresentPageApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.task {
try? Tips.resetDatastore()
try? Tips.configure([
.datastoreLocation(.applicationDefault)
])
}
}
}
}
import SwiftUI
struct ContentView: View {
@State private var isPresented: Bool = false
var body: some View {
NavigationStack {
VStack {
Image(systemName: "globe")
.imageScale(.large)
.foregroundStyle(.tint)
.popoverTip(MyTip())
.padding(100)
Button("Hit Me!") {
isPresented.toggle()
// When the TipKit notification appears, the 'present sheet' button will be non-functional. (iPhone SE and simulator devices)
}
.padding()
.sheet(isPresented: $isPresented) {
PresentPage()
}
}
}
}
}
import SwiftUI
struct PresentPage: View {
var body: some View {
Text("Hello, world again!")
.font(.title)
}
}
import TipKit
struct MyTip: Tip {
var title: Text {
Text("Test")
}
var message: Text? {
Text("Hi")
}
}
When the TipKit notification appears, the 'present sheet' button will be non-functional. (iPhoneSE Landscape Right)
When using the iPhone SE (Landscape Right) or its simulator (iPhone SE Landscape Right), running iOS 17.2. Whenever the TipKit notification is triggered and displayed on the screen, the 'present sheet' button, which is typically used for presenting a new sheet within the app, becomes non-functional.
Device: iPhoneSE iOS 17.2
Does anyone know how to bypass this bug? Thank you.