Getting AST from swift module

(Alexander Zalutskiy) #1

Hi, everyone.

I have some questions about parsing swift module files. I write a translator from my own interface markup language to swift code. I need to check exist classes and methods in uikit and user’s frameworks. SourceKit provides the only completion for swift files. How can I give information from swift module file about classes, methods, and properties with standard xcode toolchain? Do I need to write my own utility that works with compiler libraries and ast or can use something from existing tools?

Thanks, Alexander.

(Xi Ge) #2

@a.zalutskiy, sourcekitd's doc-info request will give you a pretty printed AST for a given module with semantic information. You can use sourcekitd-test to invoke this request. For example, this command will given you the tree for the Swift standard library: $sourcekitd-test -req=doc-info -module Swift. More examples can be found in the Swift repository's tests: DocSupport test

1 Like