Skip to content

Fall back to Xcode DerivedData when using --skip-build#1083

Open
ky1ejs wants to merge 2 commits intoperipheryapp:masterfrom
ky1ejs:fix/skip-build-xcode-derived-data-fallback
Open

Fall back to Xcode DerivedData when using --skip-build#1083
ky1ejs wants to merge 2 commits intoperipheryapp:masterfrom
ky1ejs:fix/skip-build-xcode-derived-data-fallback

Conversation

@ky1ejs
Copy link
Copy Markdown

@ky1ejs ky1ejs commented Feb 19, 2026

Summary

When --skip-build is used without --index-store-path, periphery only looks for the index store in its own DerivedData cache directory (~/Library/Caches/com.github.peripheryapp/DerivedData-*). If the build was performed by Xcode or xcodebuild directly (rather than by periphery), the index store lives in Xcode's default DerivedData location and periphery fails with Failed to find index datastore.

This is a common scenario in CI pipelines where the project is built in a prior step and periphery runs with --skip-build to avoid rebuilding.

This PR adds a fallback: when the index store isn't found in periphery's own cache, search ~/Library/Developer/Xcode/DerivedData/ for directories matching the project name, preferring the most recently modified one.

Changes

  • Extracted the index store path lookup (Index.noindex/DataStore or Index/DataStore) into a reusable findIndexStorePath(in:) method
  • Added findIndexStoreInDefaultDerivedData(projectName:) that searches Xcode's default DerivedData location
  • indexStorePath(project:schemes:) now tries periphery's cache first, then falls back to Xcode's DerivedData before throwing

Reproduction

# Build with xcodebuild (not periphery)
xcodebuild -scheme MyScheme -destination 'platform=iOS Simulator,name=iPhone 16' build

# This fails without the fix:
periphery scan --skip-build --strict
# Error: Failed to find index datastore at path: ~/Library/Caches/com.github.peripheryapp/DerivedData-...

# Workaround (no longer needed with this fix):
periphery scan --skip-build --index-store-path "$(find ~/Library/Developer/Xcode/DerivedData -path '*/Index.noindex/DataStore' -type d | head -1)" --strict

Fixes #1082

When --skip-build is used without --index-store-path, periphery looks
for the index store in its own DerivedData cache directory. However,
when the build was performed by Xcode or xcodebuild directly, the index
store lives in Xcode's default DerivedData location instead.

This adds a fallback that searches ~/Library/Developer/Xcode/DerivedData
for a matching project directory when the index store is not found in
periphery's own cache. The most recently modified matching directory is
preferred.

Fixes peripheryapp#1082
Make findIndexStorePath and findIndexStoreInDerivedData internal for
testability. Extract the core DerivedData search into a
findIndexStoreInDerivedData(projectName:derivedDataRoot:) overload that
accepts a custom root path, enabling unit tests with temp directories.

Add 11 tests covering both findIndexStorePath and the DerivedData
fallback: modern vs legacy index layouts, preference ordering, project
name matching edge cases, and most-recently-modified selection.
@ky1ejs ky1ejs force-pushed the fix/skip-build-xcode-derived-data-fallback branch from d0ddb45 to 349cb37 Compare February 19, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--skip-build without --index-store-path fails to find Xcode's index store

1 participant