跳到正文
TakoAPI
返回技能列表

swiftfindrefs

由 michaelversus 提供

iOS & macOS Development
1.6k下载量由 clawskills.sh 提供
1星标
0浏览量
0 个赞登录后即可为这个技能点赞
—暂无评分
你的评分

简介

Use swiftfindrefs (IndexStoreDB) to list every Swift source.

描述

该技能的功能

swiftfindrefs queries Xcode's IndexStore (DerivedData) to return every Swift source file that references a given symbol. It covers classes, structs, enums, protocols, functions, and variables across modules. Output is one absolute file path per line, deduplicated and safe to pipe.

grep and IDE search operate on text and miss references that the compiler resolved through type inference or module re-exports, while IndexStoreDB reflects what was actually compiled.

何时使用

  • Finding all callers of a function before renaming it
  • Auditing files affected by moving a type to a new module
  • Adding missing imports only to files that reference a relocated symbol
  • Confirming a symbol is unused before deleting it
  • Scoping a cross-module refactor to exactly the files that matter

示例工作流

输入

User asks: find all Swift files referencing UserSession before renaming it

智能体
  1. 1

    Run swiftfindrefs --projectName MyApp --symbolName UserSession --symbolType class

  2. 2

    Collect the list of absolute file paths from stdout

  3. 3

    Open only those files to review call sites

  4. 4

    Rename UserSession in each returned file

  5. 5

    Verify no other files were changed

输出

A deduplicated list of absolute paths to every .swift file referencing UserSession, ready for targeted edits

前置要求

  • Xcode installed on macOS (project must be built at least once to populate DerivedData)
  • swiftfindrefs CLI installed via Homebrew: brew tap michaelversus/SwiftFindRefs https://github.com/michaelversus/SwiftFindRefs.git && brew install swiftfindrefs

安装

clawhub install michaelversus/swiftfindrefs

运行 CLI 命令,或把这段提示词粘贴到 Claude Code、Cursor、Codex 或你在用的任意编程智能体里。

链接