Skip to content

Instantly share code, notes, and snippets.

@annidy
Forked from caius/ShowDerivedData.rb
Created October 27, 2021 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save annidy/45e342c438b9226499e942142580b5d0 to your computer and use it in GitHub Desktop.
Save annidy/45e342c438b9226499e942142580b5d0 to your computer and use it in GitHub Desktop.
A script for showing the derived data folder for an Xcode workspace. Intended to be invoked from a custom behaviour
#!/usr/bin/env ruby
# This script currently only works if you have your derived data in the default location.
# Get the workspace name to search for, or exit with code 1 if no value in envariable
xcodeWorkspacePath = ENV["XcodeWorkspacePath"] || exit(1)
projectName = xcodeWorkspacePath[%r{/(\w+)\.xcodeproj}, 1]
#Get the folders in derived data that could match the workspace
derived_data = File.expand_path("~/Library/Developer/Xcode/DerivedData")
# Glob out the files matching our project
Dir["#{derived_data}/#{projectName}*"].each do |folder|
# Passing args in this fashion auto-escapes them
exec "open", folder
end
__END__
Example value for ENV["XcodeWorkspacePath"] is "/Users/caius/Projects/SkypeAnySize/SkypeAnySize.xcodeproj/project.xcworkspace" (Xcode 4.2, 10.7 mac app project)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment