Post

Replies

Boosts

Views

Activity

Reply to How do I back up and restore swiftdata DB files?
Hi! You could setup the ModelContainer manually (to know when the SwiftData stack is being initialised and probably also to have the possibility to decide what the files are named and where they are stored) and backup/copy those files beforehand. By manually setting up the stack I mean something like that: let dbRootURL = (URL.documentsDirectory) let dbURL = dbRootURL.appendingPathComponent("TheDB.db") // open the db let fullSchema = Schema(ModelV3.models) let dbCfg = ModelConfiguration(schema: fullSchema, url: dbURL) return try ModelContainer(for: fullSchema, migrationPlan: DBMigrationPlan.self, configurations: dbCfg) Those are pretty much the standard files. Other than that "default.store" has usually renaming the "sqlite" extension. Maybe that confuses the tools you are using. Try renaming it to .sqlite and see if it helps. Cheers, Michael
Aug ’23
Reply to Can't set default values for @Model vars
I think this relates to this issue mentioned in the release notes of Xcode Beta 6: @Model classes with initial values for stored properties result in an error that self._$backingData is used before being initialized. (113572344) Workaround: Assign initial values to stored properties in the body of an initializer. For example, instead of this code: [...]
Aug ’23
Reply to NavigationStack Being Automatically dismissed
I ran into basically the same problem. Below is the smallest sample app I came up with demonstrating this issue. It does not happen the first time you navigate in the stack, but on all subsequent times. I filed FB10662166 - feel free to reference in you feedbacks ;-) import SwiftUI struct SidebarEntry: Identifiable, Hashable { let id = UUID() var localizedName: String } let sidebarEntries = [ SidebarEntry(localizedName: "Files"), SidebarEntry(localizedName: "Bookmarks"), ] // MARK: - main - @main struct NewNavigationTestApp: App { @State private var sidebarSelection: SidebarEntry? var body: some Scene { WindowGroup { NavigationSplitView { List(sidebarEntries, selection: $sidebarSelection) { entry in NavigationLink("\(entry.localizedName)", value: entry) } } detail: { ZStack { // workaround if let sidebarSelection { if sidebarSelection.localizedName == "Files" { TestStackView() } else if sidebarSelection.localizedName == "Bookmarks" { Text("Bookmarks View") } else { Text("Unknown View") } } else { Text("No selection") } } } } } } // MARK: - FilesView - struct TestStackView: View { var body: some View { NavigationStack { List(0 ..< 999) { idx in NavigationLink("\(idx)", value: idx) } } .navigationTitle("Numbers") .navigationDestination(for: Int.self) { idx in Text("Hello") } } }
Jul ’22
Reply to @State not updating when set via .init([...]) parameter
Unfortunately @MobileTen's suggestion with the @Binding does not work in my case, since I need to modify _internalNumber from within TestView as well. This was not mentioned in my problem description above. The problem case here really is to have an internal @State initialized from an external value and being able to change that "State". Once the "outside" number changes (in ContentView, I would expect TestView.init to be called again (which actually happens), TestView.body to be called again (which also happens) and the changed number to be displayed (which does not happen ;-))
Jun ’22
Reply to @SceneStorage not working on macOS
Seems like nobody is using SwiftUI on macOS :-( So far I tried it on three different machines (all running the lates macOS/Xcode). One even installed from scratch, to be sure it's nothing in my installation. So my guess is, that it's just broken. I filed FB10011754 for this. Anyway if somebody has @SceneStorage working on macOS I would like to hear from you and maybe figure out what's different that makes it work.
May ’22
Reply to Crashes in _os_semaphore_dispose.cold since Xcode 13 beta 5
At least it's good not to be alone ;-). Filed as FB9487340. The simplest example I found, was just having a TextField and tapping on it after a reset of the simulator. Once the keyboard appears and shows the "swipe to type" instructions the crash occurs. The reset of the simulator is necessary so that the "swipe to type" instructions appear, which seem to be the causing the crash in that case.
Aug ’21