Post

Replies

Boosts

Views

Activity

Reply to SwiftUI previews fail with a very simple SwiftPM package
Try wrapping the preview code in the following or something like below. #if arch(arm64) && os(macOS) || os(iOS) import SwiftUI struct Test: View { var body: some View { Text("Hello world") } } #Preview { Test() } #endif Read here: https://forums.swift.org/t/swift-package-is-built-as-a-universal-binary-in-main-project/54075 or replace preview macro with struct Test_Previews: PreviewProvider { static var previews: some View { Test() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’24
Reply to Query with Predicate
The variable is being used before any initialization has taken place. selectedStagione can be replaced with a constant or static value. Then within the body of the code, a refetch of the data, using the modelContext.fetch() can be done in response to some kind of change. @Query(filter: #Predicate<CalendarioPartite> { $0.stagione == selectedStagione}) private var partite: [CalendarioPartite]
May ’24