返回顶部
s

swiftfindrefs快速查找引用

Use swiftfindrefs (IndexStoreDB) to list every Swift source file referencing a symbol. Mandatory for “find references”, “fix missing imports”, and cross-module refactors. Do not replace with grep/rg or IDE search.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.5
安全检测
已通过
1,860
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

swiftfindrefs

SwiftFindRefs

目的

使用 swiftfindrefs 通过查询 Xcode 的 IndexStore(DerivedData)来定位所有引用给定符号的 Swift 源文件。此技能旨在防止因文本搜索或启发式方法导致的不完整重构。

规则

  • - 在编辑任何文件之前,始终运行 swiftfindrefs。
  • 仅编辑 swiftfindrefs 返回的文件。
  • 不得使用 grep、rg、IDE 搜索或文件系统启发式方法替代引用发现。
  • 不得手动扩展文件集。
  • 如果 IndexStore/DerivedData 解析失败,请停止并报告错误。不要猜测。

前置条件

  • - 已安装 Xcode 的 macOS 系统
  • 项目至少已构建一次(DerivedData 存在)
  • swiftfindrefs 在 PATH 中可用

安装

bash brew tap michaelversus/SwiftFindRefs https://github.com/michaelversus/SwiftFindRefs.git brew install swiftfindrefs

标准命令

尽可能提供 --projectName 和 --symbolType。

bash
swiftfindrefs \
--projectName \
--symbolName <符号名称> \
--symbolType

可选标志:

  • - --dataStorePath <路径>:显式指定 DataStore(或 IndexStoreDB)路径;跳过自动发现
  • -v, --verbose:启用详细输出以进行诊断(标志,无需值)

输出约定

  • - 每行一个绝对文件路径
  • 去重处理
  • 脚本友好(可安全地逐行管道传输)
  • 排序无语义意义

标准工作流程

工作流程 A:查找所有引用

  1. 1. 对符号运行 swiftfindrefs。
  2. 将输出视为完整的引用集。
  3. 如果需要更多详细信息,仅打开返回的文件。

工作流程 B:移动符号后修复缺失的导入

使用 swiftfindrefs 限定范围,然后仅在需要的地方添加导入。

bash
swiftfindrefs -p <项目> -n <符号> -t <类型> | while read file; do
if ! grep -q ^import <模块名称>$ $file; then
echo $file
fi
done

然后对每个打印的文件:

  • - 在顶部的导入块中插入 import <模块名称>。
  • 保留现有的导入排序/分组。
  • 切勿添加重复的导入。
  • 不要重新格式化无关代码。

工作流程 C:删除或重命名符号前审计使用情况

  1. 1. 对符号运行 swiftfindrefs。
  2. 如果输出为空,则将该符号视为未使用(必要时仍通过构建/测试验证)。
  3. 如果非空,在更改公共 API 前审查列出的文件。

参考资料

  • - CLI 详情:references/cli.md
  • 操作手册:references/workflows.md
  • 故障排除:references/troubleshooting.md

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 swiftfindrefs-1776375425 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 swiftfindrefs-1776375425 技能

通过命令行安装

skillhub install swiftfindrefs-1776375425

下载

⬇ 下载 swiftfindrefs v1.0.5(免费)

文件大小: 3.87 KB | 发布时间: 2026-4-17 16:19

v1.0.5 最新 2026-4-17 16:19
- Added installation instructions using Homebrew for swiftfindrefs.
- Updated optional argument: replaced --derivedDataPath with --dataStorePath for specifying IndexStoreDB location.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部