Skip to content

Instantly share code, notes, and snippets.

@DavidPiper94
Last active April 9, 2020 05:28
Show Gist options
  • Select an option

  • Save DavidPiper94/034f6836a1433899b42fb817cf46ab4f to your computer and use it in GitHub Desktop.

Select an option

Save DavidPiper94/034f6836a1433899b42fb817cf46ab4f to your computer and use it in GitHub Desktop.
Example code for article about SourceKitten - Analyzing the source code
// 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