Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to get all struct types in Swift-3 runtime?

Tags:

swift

swift3

Something like objc_getClassList but for structs.

Just to give some context: this method (for classes) is used in our unit tests to test that all classes with certain suffix have tests for them. We test the tests!

like image 680
Peter Prokop Avatar asked Jan 24 '17 13:01

Peter Prokop


1 Answers

The Swift compiler mostly emits enough metadata to do this kind of reflection today but it isn't exposed. Full-fidelity reflection is on the "list of things we'd like to do" but has not yet been implemented.

like image 196
russbishop Avatar answered Oct 28 '22 10:10

russbishop