Last active
April 9, 2020 05:28
-
-
Save DavidPiper94/034f6836a1433899b42fb817cf46ab4f to your computer and use it in GitHub Desktop.
Example code for article about SourceKitten - Analyzing the source code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 1 | |
| import SourceKittenFramework | |
| // 2 | |
| let file = File(path: "/path/to/sourcefile.swift")! | |
| // 3 | |
| let code = """ | |
| import UIKit | |
| class ViewController: UIViewController { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // Do any additional setup after loading the view. | |
| } | |
| } | |
| """ | |
| let file = File(contents: code) | |
| // 4 | |
| let structure = try! Structure(file: file) | |
| let description = structure.description |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment