fastlane/lib/fastlane/actions/clear_derived_data.rb in fastlane-2.90.0.beta.20180405050125 vs fastlane/lib/fastlane/actions/clear_derived_data.rb in fastlane-2.90.0.beta.20180406050006

- old
+ new

@@ -1,32 +1,47 @@ +require 'fastlane_core/core_ext/cfpropertylist' + module Fastlane module Actions class ClearDerivedDataAction < Action def self.run(options) path = File.expand_path(options[:derived_data_path]) UI.message("Derived Data path located at: #{path}") FileUtils.rm_rf(path) if File.directory?(path) UI.success("Successfully cleared Derived Data ♻️") end + # Helper Methods + def self.xcode_preferences + file = File.expand_path("~/Library/Preferences/com.apple.dt.Xcode.plist") + if File.exist?(file) + plist = CFPropertyList::List.new(file: file).value + return CFPropertyList.native_types(plist) unless plist.nil? + end + return nil + end + ##################################################### # @!group Documentation ##################################################### def self.description "Deletes the Xcode Derived Data" end def self.details - "Deletes the Derived Data from '~/Library/Developer/Xcode/DerivedData' or a supplied path" + "Deletes the Derived Data from path set on Xcode or a supplied path" end def self.available_options + path = xcode_preferences ? xcode_preferences['IDECustomDerivedDataLocation'] : nil + path ||= "~/Library/Developer/Xcode/DerivedData" [ FastlaneCore::ConfigItem.new(key: :derived_data_path, env_name: "DERIVED_DATA_PATH", description: "Custom path for derivedData", - default_value: "~/Library/Developer/Xcode/DerivedData") + default_value_dynamic: true, + default_value: path) ] end def self.output end