Created
November 5, 2011 14:24
-
-
Save pilky/1341574 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#This script currently only works if you have your derived data in the default location | |
#First look for a project path as our workspace | |
xcodeWorkspacePath = ENV['XcodeProjectPath'] | |
if xcodeWorkspacePath | |
workspaceName = /([\w\s]+).xcodeproj/.match(xcodeWorkspacePath)[1] | |
#If we don't have a project we have a workspace, check for that and exit with code 1 if that doesn't exist | |
else | |
xcodeWorkspacePath = ENV['XcodeWorkspacePath'] || exit(1) | |
workspaceName = /([\w\s]+).xcworkspace/.match(xcodeWorkspacePath)[1] | |
end | |
#Replace spaces with underscores | |
workspaceName = workspaceName.sub(/ /, "_") | |
#Loop through through the folders and check their workspace path to see if they match | |
derived_data = File.expand_path("~/Library/Developer/Xcode/DerivedData") | |
Dir["#{derived_data}/#{workspaceName}*"].each do |folder| | |
info = File.read("#{folder}/info.plist"); | |
workspacePath = /<key>WorkspacePath<\/key>\s*<string>(.*?)<\/string>/.match(info)[1] | |
if workspacePath == xcodeWorkspacePath | |
%x[open "#{folder}"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment