{"id":3146,"url":"https://github.com/jpsim/SourceKitten","last_synced_at":"2025-08-03T13:32:02.239Z","repository":{"id":19790059,"uuid":"23049318","full_name":"jpsim/SourceKitten","owner":"jpsim","description":"An adorable little framework and command line tool for interacting with SourceKit.","archived":false,"fork":false,"pushed_at":"2024-10-28T18:55:42.000Z","size":9641,"stargazers_count":2307,"open_issues_count":100,"forks_count":226,"subscribers_count":40,"default_branch":"main","last_synced_at":"2024-10-29T11:06:34.397Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpsim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-08-17T20:07:25.000Z","updated_at":"2024-10-22T11:18:12.000Z","dependencies_parsed_at":"2024-02-04T14:29:05.365Z","dependency_job_id":"183501ca-1b38-48b0-bed6-7f083feea2fa","html_url":"https://github.com/jpsim/SourceKitten","commit_stats":{"total_commits":1524,"total_committers":79,"mean_commits":19.29113924050633,"dds":"0.38320209973753283","last_synced_commit":"3db807287138663188c4f74728375a13b1057c06"},"previous_names":[],"tags_count":94,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpsim%2FSourceKitten","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpsim%2FSourceKitten/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpsim%2FSourceKitten/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpsim%2FSourceKitten/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpsim","download_url":"https://codeload.github.com/jpsim/SourceKitten/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227476152,"owners_count":17779416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:16:32.731Z","updated_at":"2024-12-07T01:30:36.402Z","avatar_url":"https://github.com/jpsim.png","language":"Swift","funding_links":[],"categories":["Tools","Swift","WebSocket","The Index"],"sub_categories":["Web View","Other free courses","System Libraries"],"readme":"# SourceKitten\n\nAn adorable little framework and command line tool for interacting with [SourceKit][uncovering-sourcekit].\n\nSourceKitten links and communicates with `sourcekitd.framework` to parse the Swift AST, extract comment docs for Swift or Objective-C projects, get syntax data for a Swift file and lots more!\n\n![SwiftPM](https://github.com/jpsim/SourceKitten/workflows/SwiftPM/badge.svg)\n\n## Installation\n\nBuilding SourceKitten requires Xcode 13.3 or later or a Swift 5.6\ntoolchain or later with the Swift Package Manager.\n\nSourceKitten typically supports previous versions of SourceKit.\n\n### Homebrew\n\nRun `brew install sourcekitten`.\n\n### Swift Package Manager\n\nRun `swift build` in the root directory of this project.\n\n### Bazel\n\nAdd the following to your `WORKSPACE` file:\n\n```python\nSOURCEKITTEN_VERSION = \"SOME_VERSION\"\nSOURCEKITTEN_SHA = \"SOME_SHA\"\nhttp_archive(\n    name = \"com_github_jpsim_sourcekitten\",\n    url = \"https://github.com/jpsim/SourceKitten/archive/refs/tags/%s.tar.gz\" % (SOURCEKITTEN_VERSION),\n    sha256 = SOURCEKITTEN_SHA,\n    strip_prefix = \"SourceKitten-%s\" % SOURCEKITTEN_VERSION\n)\n```\n\nThen run: `bazel run @com_github_jpsim_sourcekitten//:sourcekitten -- -h`\n\n### Xcode (via Make)\n\nRun `make install` in the root directory of this project.\n\n### Package\n\nDownload and open SourceKitten.pkg from the [releases tab](https://github.com/jpsim/SourceKitten/releases).\n\n## Command Line Usage\n\nOnce SourceKitten is installed, you may use it from the command line.\n\n```\n$ sourcekitten help\nOVERVIEW: An adorable little command line tool for interacting with SourceKit\n\nUSAGE: sourcekitten \u003csubcommand\u003e\n\nOPTIONS:\n  --version               Show the version.\n  -h, --help              Show help information.\n\nSUBCOMMANDS:\n  complete                Generate code completion options\n  doc                     Print Swift or Objective-C docs as JSON\n  format                  Format Swift file\n  index                   Index Swift file and print as JSON\n  module-info             Obtain information about a Swift module and print as JSON\n  request                 Run a raw SourceKit request\n  structure               Print Swift structure information as JSON\n  syntax                  Print Swift syntax information as JSON\n  version                 Display the current version of SourceKitten\n\n  See 'sourcekitten help \u003csubcommand\u003e' for detailed help.\n```\n\n## How is SourceKit resolved?\n\nSourceKitten searches for SourceKit in the following order:\n\n* `$XCODE_DEFAULT_TOOLCHAIN_OVERRIDE`\n* `$TOOLCHAIN_DIR`\n* `xcrun -find swift`\n* `/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain`\n* `/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain`\n* `~/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain`\n* `~/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain`\n\nOn Linux, SourceKit is expected to be located in\n`/usr/lib/libsourcekitdInProc.so` or specified by the `LINUX_SOURCEKIT_LIB_PATH`\nenvironment variable.\n\n## Projects Built With SourceKitten\n\n* [SwiftLint](https://github.com/realm/SwiftLint):\n  A tool to enforce Swift style and conventions.\n* [Jazzy](https://github.com/realm/Jazzy):\n  Soulful docs for Swift \u0026 Objective-C.\n* [Sourcery](https://github.com/krzysztofzablocki/Sourcery):\n  Meta-programming for Swift, stop writing boilerplate code.\n* [SwiftyMocky](https://github.com/MakeAWishFoundation/SwiftyMocky):\n  Framework for mock generation.\n* [SourceKittenDaemon](https://github.com/terhechte/SourceKittenDaemon):\n  Swift Auto Completions for any Text Editor.\n* [SourceDocs](https://github.com/eneko/SourceDocs):\n  Command Line Tool that generates Markdown documentation from inline source\n  code comments.\n* [Cuckoo](https://github.com/Brightify/Cuckoo):\n  First boilerplate-free mocking framework for Swift.\n* [IBAnalyzer](https://github.com/fastred/IBAnalyzer): Find common xib and\n  storyboard-related problems without running your app or writing unit tests.\n* [Taylor](https://github.com/yopeso/Taylor): Measure Swift code metrics and\n  get reports in Xcode, Jenkins and other CI platforms.\n\n\u003cdetails\u003e\n  \u003csummary\u003eSee More\u003c/summary\u003e\n\n  * https://github.com/appsquickly/TyphoonSwift\n  * https://github.com/banjun/bansan\n  * https://github.com/Beaver/BeaverCodeGen\n  * https://github.com/Ben-G/Meet\n  * https://github.com/dfreemanRIIS/ETAMock\n  * https://github.com/dostu/SwiftMetric\n  * https://github.com/draven-archive/MetaKit\n  * https://github.com/geosor/SwiftVisualizer\n  * https://github.com/godfreynolan/AgileSwiftTst\n  * https://github.com/godfreynolan/CodeCraftsman\n  * https://github.com/ilyapuchka/dipgen\n  * https://github.com/ilyapuchka/SourceKittenEditorExtension\n  * https://github.com/interstateone/Unused\n  * https://github.com/ishkawa/DIKit\n  * https://github.com/IvanovGeorge/FBAuth\n  * https://github.com/jmpg93/NavigatorSwift\n  * https://github.com/jpmartha/Pancake\n  * https://github.com/jpweber/Kontext\n  * https://github.com/KenichiroSato/CatDogTube\n  * https://github.com/klundberg/grift\n  * https://github.com/kovtun1/DependenciesGraph\n  * https://github.com/lvsti/Bridgecraft\n  * https://github.com/maralla/completor-swift\n  * https://github.com/marcsnts/Shopify-Winter18-Technical\n  * https://github.com/momentumworks/Formula\n  * https://github.com/nevil/UNClassDiagram\n  * https://github.com/norio-nomura/LinuxSupportForXcode\n  * https://github.com/paulofaria/swift-package-crawler-data\n  * https://github.com/rajat-explorer/Github-Profiler\n  * https://github.com/rockbruno/swiftshield\n  * https://github.com/S2dentik/Enlight\n  * https://github.com/seanhenry/SwiftMockGeneratorForXcode\n  * https://github.com/sharplet/swiftags\n  * https://github.com/siejkowski/Croupier\n  * https://github.com/SwiftKit/CuckooGenerator\n  * https://github.com/SwiftKit/Torch\n  * https://github.com/SwiftTools/SwiftFelisCatus\n  * https://github.com/swizzlr/lux\n  * https://github.com/tid-kijyun/XcodeSourceEditorExtension-ProtocolImplementation\n  * https://github.com/tjarratt/fake4swift\n  * https://github.com/tkohout/Genie\n  * https://github.com/tomquist/MagicMirror\n  * https://github.com/TurfDb/TurfGen\n  * https://github.com/vadimue/AwesomeWeather\n  * https://github.com/yonaskolb/Beak\n  * https://github.com/zenzz/vs-swifter-server\n  * https://github.com/zenzz/zxxswifter-server\n  * https://github.com/scribd/Weaver\n  * https://github.com/Nonchalant/FactoryProvider\n\u003c/details\u003e\n\n## Complete\n\nRunning `sourcekitten complete --file file.swift --offset 123` or\n`sourcekitten complete --text \"0.\" --offset 2` will print out code completion\noptions for the offset in the file/text provided:\n\n```json\n[{\n  \"descriptionKey\" : \"advancedBy(n: Distance)\",\n  \"associatedUSRs\" : \"s:FSi10advancedByFSiFSiSi s:FPSs21RandomAccessIndexType10advancedByuRq_S__Fq_Fqq_Ss16ForwardIndexType8Distanceq_ s:FPSs16ForwardIndexType10advancedByuRq_S__Fq_Fqq_S_8Distanceq_ s:FPSs10Strideable10advancedByuRq_S__Fq_Fqq_S_6Strideq_ s:FPSs11_Strideable10advancedByuRq_S__Fq_Fqq_S_6Strideq_\",\n  \"kind\" : \"source.lang.swift.decl.function.method.instance\",\n  \"sourcetext\" : \"advancedBy(\u003c#T##n: Distance##Distance#\u003e)\",\n  \"context\" : \"source.codecompletion.context.thisclass\",\n  \"typeName\" : \"Int\",\n  \"moduleName\" : \"Swift\",\n  \"name\" : \"advancedBy(n: Distance)\"\n},\n{\n  \"descriptionKey\" : \"advancedBy(n: Self.Distance, limit: Self)\",\n  \"associatedUSRs\" : \"s:FeRq_Ss21RandomAccessIndexType_SsS_10advancedByuRq_S__Fq_FTqq_Ss16ForwardIndexType8Distance5limitq__q_\",\n  \"kind\" : \"source.lang.swift.decl.function.method.instance\",\n  \"sourcetext\" : \"advancedBy(\u003c#T##n: Self.Distance##Self.Distance#\u003e, limit: \u003c#T##Self#\u003e)\",\n  \"context\" : \"source.codecompletion.context.superclass\",\n  \"typeName\" : \"Self\",\n  \"moduleName\" : \"Swift\",\n  \"name\" : \"advancedBy(n: Self.Distance, limit: Self)\"\n},\n...\n]\n```\n\nTo use the iOS SDK, pass `-sdk` and `-target` arguments preceded by `--`:\n```\nsourcekitten complete --text \"import UIKit ; UIColor.\" --offset 22 -- -target arm64-apple-ios9.0 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk\n```\n\n## Doc\n\nRunning `sourcekitten doc` will pass all arguments after what is parsed to\n`xcodebuild` (or directly to the compiler, SourceKit/clang, in the\n`--single-file` mode).\n\n### Example usage\n\n1. `sourcekitten doc -- -workspace SourceKitten.xcworkspace -scheme SourceKittenFramework`\n2. `sourcekitten doc --single-file file.swift -- -j4 file.swift`\n3. `sourcekitten doc --module-name Alamofire -- -project Alamofire.xcodeproj`\n4. `sourcekitten doc -- -workspace Haneke.xcworkspace -scheme Haneke`\n5. `sourcekitten doc --objc Realm/Realm.h -- -x objective-c -isysroot $(xcrun --show-sdk-path) -I $(pwd)`\n\n## Structure\n\nRunning `sourcekitten structure --file file.swift` or `sourcekitten structure --text \"struct A { func b() {} }\"` will return a JSON array of structure information:\n\n```json\n{\n  \"key.substructure\" : [\n    {\n      \"key.kind\" : \"source.lang.swift.decl.struct\",\n      \"key.offset\" : 0,\n      \"key.nameoffset\" : 7,\n      \"key.namelength\" : 1,\n      \"key.bodyoffset\" : 10,\n      \"key.bodylength\" : 13,\n      \"key.length\" : 24,\n      \"key.substructure\" : [\n        {\n          \"key.kind\" : \"source.lang.swift.decl.function.method.instance\",\n          \"key.offset\" : 11,\n          \"key.nameoffset\" : 16,\n          \"key.namelength\" : 3,\n          \"key.bodyoffset\" : 21,\n          \"key.bodylength\" : 0,\n          \"key.length\" : 11,\n          \"key.substructure\" : [\n\n          ],\n          \"key.name\" : \"b()\"\n        }\n      ],\n      \"key.name\" : \"A\"\n    }\n  ],\n  \"key.offset\" : 0,\n  \"key.diagnostic_stage\" : \"source.diagnostic.stage.swift.parse\",\n  \"key.length\" : 24\n}\n```\n\n## Syntax\n\nRunning `sourcekitten syntax --file file.swift` or `sourcekitten syntax --text \"import Foundation // Hello World\"` will return a JSON array of syntax highlighting information:\n\n```json\n[\n  {\n    \"offset\" : 0,\n    \"length\" : 6,\n    \"type\" : \"source.lang.swift.syntaxtype.keyword\"\n  },\n  {\n    \"offset\" : 7,\n    \"length\" : 10,\n    \"type\" : \"source.lang.swift.syntaxtype.identifier\"\n  },\n  {\n    \"offset\" : 18,\n    \"length\" : 14,\n    \"type\" : \"source.lang.swift.syntaxtype.comment\"\n  }\n]\n```\n\n## Request\n\nRunning `sourcekitten request --yaml [FILE|TEXT]` will execute a sourcekit request with the given yaml. For example:\n\n```yaml\nkey.request: source.request.cursorinfo\nkey.sourcefile: \"/tmp/foo.swift\"\nkey.offset: 8\nkey.compilerargs:\n  - \"/tmp/foo.swift\"\n```\n\n## SourceKittenFramework\n\nMost of the functionality of the `sourcekitten` command line tool is actually encapsulated in a framework named SourceKittenFramework.\n\nIf you’re interested in using SourceKitten as part of another tool, or perhaps extending its functionality, take a look at the SourceKittenFramework source code to see if the API fits your needs.\n\n*Note: SourceKitten is written entirely in Swift, and the SourceKittenFramework API is not designed to interface with Objective-C.*\n\n## License\n\nMIT licensed.\n\n[uncovering-sourcekit]: http://jpsim.com/uncovering-sourcekit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpsim%2FSourceKitten","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpsim%2FSourceKitten","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpsim%2FSourceKitten/lists"}