[swift-users] Reason for Swift not having readwrite reflection

Jens Alfke jens at mooseyard.com
Thu Dec 17 18:59:20 CST 2015

> On Dec 17, 2015, at 10:54 AM, Gergely Orosz via swift-users <swift-users at swift.org> wrote:
> Not having readwrite reflection makes it impossible to create any mocking frameworks for unit testing

I also strongly want reflection, but for a different purpose: data modeling. Core Data’s NSManagedObject is an example of what can be done with Objective-C: you just subclass it and add @property declarations, and the framework takes care of implementing those properties and backing them with data from a database. I happen to work on a different database (Couchbase Lite) that has a similar mechanism that uses the same Obj-C reflection capabilities. Our CBLModel class can be used in Swift since it inherits from NSObject, but in the long run I’d prefer to be able to do this with a pure-Swift class.

I’m glad to hear from Joe Groff that this is on the road-map. This would be a good topic to discuss on the swift-evolution list; swift-users seems more targeted at using Swift-as-it-is.


More information about the swift-users mailing list