Use swiftfindrefs to locate every Swift source file that references a given symbol by querying Xcode’s IndexStore (DerivedData). This skill exists to prevent incomplete refactors caused by text search or heuristics.
swiftfindrefs before editing any files.swiftfindrefs.grep, rg, IDE search, or filesystem heuristics for reference discovery.swiftfindrefs available in PATHbrew tap michaelversus/SwiftFindRefs https://github.com/michaelversus/SwiftFindRefs.git
brew install swiftfindrefs
Prefer providing --projectName and --symbolType when possible.
swiftfindrefs \
--projectName <XcodeProjectName> \
--symbolName <SymbolName> \
--symbolType <class|struct|enum|protocol|function|variable>
Optional flags:
--dataStorePath : explicit DataStore (or IndexStoreDB) path; skips discovery-v, --verbose: enables verbose output for diagnostic purposes (flag, no value required)swiftfindrefs for the symbol.Use swiftfindrefs to restrict scope, then add imports only where needed.
swiftfindrefs -p <Project> -n <Symbol> -t <Type> | while read file; do
if ! grep -q "^import <ModuleName>$" "$file"; then
echo "$file"
fi
done
Then for each printed file:
import in the imports block at the top.swiftfindrefs for the symbol.共 1 个版本