Post

Replies

Boosts

Views

Activity

Reply to SwiftData #Predicate cannot test for nil relationship
I did a bit more experimenting. The problem doesn't seem to be in the optionality of the types per se, as even the following doesn't work: @Model final class Item { var timestamp: Date var group: Group } @Model final class Group { var name: String var items: [Item] } What does work is comparing the objects' IDs: This works: func query(group: Group) { let id = group.id let predicate = #Predicate<Item> { item in item.group?.id == id // Compiles } } However, if the id is not in a local variable, the Predicate macro doesn't compile: func query(group: Group) { let predicate = #Predicate<Item> { item in item.group?.id == group.id // Doesn't compile } }
Sep ’23
Reply to SwiftData #Predicate cannot test for nil relationship
@newwbee Can you please show your code? I have just tested and neither of those variations (where you put the inverse) work: @Model final class Item { var timestamp: Date @Relationship var group: Group? } @Model final class Group { var name: String @Relationship(inverse: \Item.group) var items: [Item] } @Model final class Item { var timestamp: Date @Relationship(inverse: \Group.items) var group: Group? } @Model final class Group { var name: String @Relationship var items: [Item] }
Sep ’23
Reply to SwiftData #Predicate cannot test for nil relationship
Still an issue with the final release of iOS 17. Given the following models (initializers omitted for brevity): @Model final class Item { var timestamp: Date var group: Group? } @Model final class Group { var name: String var items: [Item] } This predicate doesn't compile: func query(group: Group) { let predicate = #Predicate<Item> { $0.group == group } } Force-unwrapping doesn't work either: $0.group! == group.
Sep ’23
Reply to Console app not showing info and debug logs
This is still an issue—debug messages are not showing in Console.app, running macOS Sonoma 14.5 and Xcode 16.0 beta 4. Xcode's own Console works fine.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’24
Reply to SwiftData #Predicate cannot test for nil relationship
Apple confirmed that capturing group.id is the correct way to do it. They explained that the reason for that is because the predicate requires all captured values to be Codable and Sendable. And since Group is neither, it won't work and requires a local capture. I haven't tested this further, as I am not actively exploring moving to iOS 17 at this point.
Replies
Boosts
Views
Activity
Oct ’23
Reply to SwiftData #Predicate cannot test for nil relationship
I did a bit more experimenting. The problem doesn't seem to be in the optionality of the types per se, as even the following doesn't work: @Model final class Item { var timestamp: Date var group: Group } @Model final class Group { var name: String var items: [Item] } What does work is comparing the objects' IDs: This works: func query(group: Group) { let id = group.id let predicate = #Predicate<Item> { item in item.group?.id == id // Compiles } } However, if the id is not in a local variable, the Predicate macro doesn't compile: func query(group: Group) { let predicate = #Predicate<Item> { item in item.group?.id == group.id // Doesn't compile } }
Replies
Boosts
Views
Activity
Sep ’23
Reply to SwiftData #Predicate cannot test for nil relationship
@newwbee Can you please show your code? I have just tested and neither of those variations (where you put the inverse) work: @Model final class Item { var timestamp: Date @Relationship var group: Group? } @Model final class Group { var name: String @Relationship(inverse: \Item.group) var items: [Item] } @Model final class Item { var timestamp: Date @Relationship(inverse: \Group.items) var group: Group? } @Model final class Group { var name: String @Relationship var items: [Item] }
Replies
Boosts
Views
Activity
Sep ’23
Reply to SwiftData #Predicate cannot test for nil relationship
Still an issue with the final release of iOS 17. Given the following models (initializers omitted for brevity): @Model final class Item { var timestamp: Date var group: Group? } @Model final class Group { var name: String var items: [Item] } This predicate doesn't compile: func query(group: Group) { let predicate = #Predicate<Item> { $0.group == group } } Force-unwrapping doesn't work either: $0.group! == group.
Replies
Boosts
Views
Activity
Sep ’23
Reply to Sign In With Apple not working with Xcode 12 beta on simulator ?
Oh, for crying out loud, Apple! What is this? Another half-baked feature, as if we didn't get enough of these already (SwiftUI, Mac Catalyst, Xcode previews, ...).
Replies
Boosts
Views
Activity
Apr ’21