Skip to content

Instantly share code, notes, and snippets.

@tewha
Created April 7, 2026 15:50
Show Gist options
  • Select an option

  • Save tewha/57f0b1c12f7eb519735bad4d2ba57050 to your computer and use it in GitHub Desktop.

Select an option

Save tewha/57f0b1c12f7eb519735bad4d2ba57050 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import os
import shutil
from pathlib import Path
DERIVED_DATA = Path.home() / "Library/Developer/Xcode/DerivedData"
# Directories to remove (relative to each project)
TARGET_DIRS = {
"Build/Intermediates.noindex",
"Index.noindex",
"Logs",
}
def remove_dir(path: Path):
if path.exists():
print(f"Removing: {path}")
shutil.rmtree(path, ignore_errors=True)
def clean_project(project_path: Path):
for rel in TARGET_DIRS:
target = project_path / rel
remove_dir(target)
def main():
if not DERIVED_DATA.exists():
print("DerivedData directory not found.")
return
for project in DERIVED_DATA.iterdir():
if project.is_dir():
clean_project(project)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment