Post

Replies

Boosts

Views

Activity

Reply to Problem with localising a Swift package
When you use resources from a localised framework, make sure to use methods with the bundle: parameter! Even in the framework itself. Instead of using String(localized: "some String") use String(localized: "some String", bundle: Bundle.module). Same goes for Color, NSDataAsset and so on. This fixed my issue.
Topic: Programming Languages SubTopic: Swift Tags:
Aug ’23
Reply to SwiftData - Multiple modelContexts in one modelContainer
I haven't tried this out but I think it should work something like that: Create in your parent view the new context. let container = try! ModelContainer(for: Model.self, ModelConfiguration(inMemory: true)) // or whatever works for you let localContext = ModelContext(container) Then attach the localContext to a child view. yourView .modelContext(localContext) In the child view you should have access to it via the environment. @Environment(\.modelContext) var modelContext If you want to use the same container like your original context, try originalContext.container and use that in step 1. @Query in the child view will work on the given model context. At least this is my theory. I don’t have time to check it, but maybe it helps you anyways.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to SwiftData & CloudKit: getting info about current updates
Thanks! The type .import is exactly what I was looking for. For my use case it is absolutely sufficent to inspect the end date of this event type. Once it is not nil I know the import is finished and I can do what I need to do.
Replies
Boosts
Views
Activity
Sep ’24
Reply to Problem with localising a Swift package
When you use resources from a localised framework, make sure to use methods with the bundle: parameter! Even in the framework itself. Instead of using String(localized: "some String") use String(localized: "some String", bundle: Bundle.module). Same goes for Color, NSDataAsset and so on. This fixed my issue.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Linker errors in Swift app with a framework bundle
It’s hard to tell from your screenshots but I think you need to add the frameworks to the target. Under General > Frameworks, Libraries and Embedded Content hit the + Button and add the frameworks.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Problem with localising a Swift package
To be honest, I don’t know what you mean by that.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to SwiftData - Multiple modelContexts in one modelContainer
I haven't tried this out but I think it should work something like that: Create in your parent view the new context. let container = try! ModelContainer(for: Model.self, ModelConfiguration(inMemory: true)) // or whatever works for you let localContext = ModelContext(container) Then attach the localContext to a child view. yourView .modelContext(localContext) In the child view you should have access to it via the environment. @Environment(\.modelContext) var modelContext If you want to use the same container like your original context, try originalContext.container and use that in step 1. @Query in the child view will work on the given model context. At least this is my theory. I don’t have time to check it, but maybe it helps you anyways.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’23