gym/lib/gym/detect_values.rb in fastlane-2.28.0.beta.20170418010021 vs gym/lib/gym/detect_values.rb in fastlane-2.28.0.beta.20170419010123

- old
+ new

@@ -1,5 +1,6 @@ +require 'cfpropertylist' module Gym # This class detects all kinds of default values class DetectValues # This is needed as these are more complex default values # Returns the finished config object @@ -31,13 +32,36 @@ detect_configuration detect_toolchain config[:output_name] ||= Gym.project.app_name + config[:build_path] ||= archive_path_from_local_xcode_preferences + return config end + def self.archive_path_from_local_xcode_preferences + day = Time.now.strftime("%F") # e.g. 2015-08-07 + archive_path = File.expand_path("~/Library/Developer/Xcode/Archives/#{day}/") + + path = xcode_preference_plist_path + return archive_path unless File.exist?(path.to_s) # this file only exists when you edit the Xcode preferences to set custom values + + custom_archive_path = xcode_preferences_dictionary(path)['IDECustomDistributionArchivesLocation'] + return archive_path if custom_archive_path.to_s.length == 0 + + return File.join(custom_archive_path, day) + end + # Helper Methods + + def self.xcode_preference_plist_path + File.expand_path("~/Library/Preferences/com.apple.dt.Xcode.plist") + end + + def self.xcode_preferences_dictionary(path) + CFPropertyList.native_types(CFPropertyList::List.new(file: path).value) + end def self.detect_provisioning_profile if Gym.config[:provisioning_profile_path].nil? return unless Gym.config[:use_legacy_build_api] # we only want to auto-detect the profile when using the legacy build API