Post

Replies

Boosts

Views

Activity

Reply to com.apple.dt.deviceprocesscontrolservice Code=8 Error when running WidgetBundle Targets
In case anyone else who comes across this feels frustrated that you have to choose the widget's kind because it sounds like you'll have to change that value by hand whenever you want to switch widgets... You can duplicate the Scheme, name each one after the widget you want to test with it, and set the Kind value separately for each. This way all you have to do is change your Scheme before you hit run, rather than editing it each time. Also, since it's not super clear: the _XCWidgetKind variable is set in the Run settings of the scheme > Arguments tab > WidgetKit Environment section > Kind value. (Maybe it spelled out the variable name in past versions of Xcode 🤷🏻‍♂️ I'm not sure)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’25
Reply to SwiftData Unexpected type for CompositeAttribute
The error message isn't very clear, but I think what it's trying to convey is that the type you're using isn't compatible with SwiftData (at least not yet). The reason that others have said to use a computed property instead is because you can save the data you actually need to recreate the type that doesn't work. You're already halfway doing that. I think if you were to remove the @Transient and move the clLocation assignment from your initializer into a computed property, it would work. struct SomeStruct : Codable { var latitude: Double var longitude: Double // doesn't need to be @Transient if it's computed var clLocation: CLLocationCoordinate2D { CLLocationCoordinate2D(latitude: latitude, longitude: longitude) } init(latitude: Double, longitude: Double) { self.latitude = latitude self.longitude = longitude } You did mention that I'm trying to cache instances of CLLocationCoordinate2D, rather than creating new ones every time a View renders, so those work arounds don't work around. I don't think it's all that expensive to create the CLLocationCoordinate2D as a computed property when you already have the latitude and longitude handy, but I could be mistaken.
Feb ’24