{"id":18727712,"url":"https://github.com/mobilenativefoundation/swift-index-store","last_synced_at":"2026-04-02T18:07:44.456Z","repository":{"id":62502291,"uuid":"558507042","full_name":"MobileNativeFoundation/swift-index-store","owner":"MobileNativeFoundation","description":"Library to read from Swift / clang source code indexes","archived":false,"fork":false,"pushed_at":"2026-03-28T18:38:51.000Z","size":452,"stargazers_count":157,"open_issues_count":8,"forks_count":17,"subscribers_count":9,"default_branch":"main","last_synced_at":"2026-03-28T20:37:50.267Z","etag":null,"topics":["clang","ios","lyft","swift","xcode"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MobileNativeFoundation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-10-27T17:27:01.000Z","updated_at":"2026-03-28T18:37:58.000Z","dependencies_parsed_at":"2023-12-01T20:26:51.338Z","dependency_job_id":"4af1c9a7-3d55-43d0-86cd-262d65f51c9e","html_url":"https://github.com/MobileNativeFoundation/swift-index-store","commit_stats":null,"previous_names":["mobilenativefoundation/swift-index-store","lyft/swift-index-store"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/MobileNativeFoundation/swift-index-store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileNativeFoundation%2Fswift-index-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileNativeFoundation%2Fswift-index-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileNativeFoundation%2Fswift-index-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileNativeFoundation%2Fswift-index-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MobileNativeFoundation","download_url":"https://codeload.github.com/MobileNativeFoundation/swift-index-store/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobileNativeFoundation%2Fswift-index-store/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31312744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["clang","ios","lyft","swift","xcode"],"created_at":"2024-11-07T14:18:32.489Z","updated_at":"2026-04-02T18:07:44.429Z","avatar_url":"https://github.com/MobileNativeFoundation.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swift-index-store\n\n`swift-index-store` is collection of libraries and tools for\nprogrammatically reading the source code index produced by `swiftc` and\n`clang`.\n\n## Example Usage\n\nThe `IndexStore` library is the primary entrypoint. For example if you\nwant to print all the `class`es defined in a specific file:\n\n```swift\nlet storePath = // path/to/DerivedData/index/store\nlet sourceFile = // path/to/interesting/source/file\n\n// Load the index store produced by swiftc\nlet store = try IndexStore(path: storePath)\nfor unit in store.units {\n    // Find the unit that corresponds to the source file we're interested in\n    guard unit.mainFile == sourceFile, let recordName = unit.recordName else {\n        continue\n    }\n\n    let recordReader = try RecordReader(indexStore: store, recordName: recordName)\n    recordReader.forEach { symbolOccurrence in\n        // Print class definitions in the source file\n        if symbolOccurrence.roles.contains(.definition) \u0026\u0026 symbolOccurrence.symbol.kind == .class {\n            print(symbolOccurrence.symbol.name)\n        }\n    }\n}\n```\n\nFor more examples see:\n\n- [`unnecessary-testable`](Sources/unnecessary-testable/main.swift)\n  which discovers uses of `@testable` that aren't required based on the\n  API being called by the importing file.\n- [`tycat`](Sources/tycat) which print the subtypes or supertypes of a\n  given type.\n- [`indexutil-annotate`](Sources/indexutil-annotate) which outputs\n  the index information overlaid on the given source file for debugging\n  unexpected index data.\n\n## Setup\n\nSwift Package Manager:\n\n```swift\nlet package = Package(\n    // ...\n    dependencies: [\n        .package(url: \"https://github.com/lyft/swift-index-store\", from: \"1.0.0\"),\n    ],\n    targets: [\n        .executableTarget(name: \"\u003ccommand-line-tool\u003e\", dependencies: [\n            .product(name: \"IndexStore\", package: \"swift-index-store\"),\n        ]),\n    ]\n)\n```\n\nBazel:\n\nAdd the following to your `WORKSPACE` file:\n\n```python\nSWIFT_INDEX_STORE_VERSION = \"1.1.0\"\n\nhttp_archive(\n    name = \"IndexStore\",\n    sha256 = \"b9c7dbcf100783c55d2c24e491feab943a489b485b016016dcd3f3d568836b3b\",\n    strip_prefix = \"swift-index-store-%s\" % SWIFT_INDEX_STORE_VERSION,\n    url = \"https://github.com/lyft/swift-index-store/archive/refs/tags/%s.tar.gz\" % SWIFT_INDEX_STORE_VERSION,\n)\n\nload(\n    \"@IndexStore//:repositories.bzl\",\n    \"swift_index_store_dependencies\",\n)\n\nswift_index_store_dependencies()\n```\n\nthen you can consume the target like so:\n\n```python\ndeps = [\n    \"@IndexStore\",\n]\n```\n\nXcode:\n\n1. Add the swift-index-store as a Package Dependency to your project (via File ▸ Add Packages…).\n2. Added the “IndexStore” library to your target's Frameworks and Libraries.\n3. Add `$(TOOLCHAIN_DIR)/usr/lib` to your target's Runpath Search Paths (LD_RUNPATH_SEARCH_PATHS) build setting.\n4. Add `$(TOOLCHAIN_DIR)/usr/lib` to your target's Library Search Paths (LIBRARY_SEARCH_PATHS) build setting.\n\n## How it works\n\nDuring compilation, both `swiftc` and `clang` can generate a detailed\nsource code index by providing the `-index-store-path` flag. The data\nmodel of the index is public, just not well known or well documented.\n\n`IndexStore` is a Swift wrapper over the first party `libIndexStore` C\nlibrary which is part of LLVM. Xcode and Swift for Linux contain\n`libIndexStore`, but its header is found separately in\n[apple/llvm-project's\n`indexstore.h`](https://github.com/apple/llvm-project/blob/apple/next/clang/include/indexstore/indexstore.h).\n\nFor more details on the index store's data model, see:\n\n1. Adding Index-While-Building and Refactoring to Clang: \u003chttps://www.youtube.com/watch?v=jGJhnIT-D2M\u003e\n2. High level design: \u003chttps://docs.google.com/document/d/1cH2sTpgSnJZCkZtJl1aY-rzy4uGPcrI-6RrUpdATO2Q/\u003e\n\n### How does this differ from [`indexstore-db`][indexstore-db]\n\nThe goal of this library is to provide a thin Swift layer on top of the\nC library for one shot tools that manage the structure of the index data\nthemselves. [`indexstore-db`][indexstore-db] provides more comprehensive\nsupport for querying index data as it changes across multiple builds.\n\n[indexstore-db]: https://github.com/apple/indexstore-db\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobilenativefoundation%2Fswift-index-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobilenativefoundation%2Fswift-index-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobilenativefoundation%2Fswift-index-store/lists"}