Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

Commit

Permalink
Fix detecting provisioning profiles in case of providing export optio…
Browse files Browse the repository at this point in the history
…ns as a path to plist file (fastlane#12787)
  • Loading branch information
dsokal authored and Josh Holtz committed Jun 25, 2018
1 parent f5f040a commit 70a95b0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
23 changes: 23 additions & 0 deletions gym/lib/gym/detect_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def self.set_additional_default_values
end
end

ensure_export_options_is_hash

detect_scheme
detect_platform # we can only do that *after* we have the scheme
detect_selected_provisioning_profiles # we can only do that *after* we have the platform
Expand Down Expand Up @@ -144,5 +146,26 @@ def self.detect_toolchain
Gym.config[:toolchain] = "com.apple.dt.toolchain.Swift_2_3"
end
end

def self.ensure_export_options_is_hash
return if Gym.config[:export_options].nil? || Gym.config[:export_options].kind_of?(Hash)

# Reads options from file
plist_file_path = Gym.config[:export_options]
UI.user_error!("Couldn't find plist file at path #{File.expand_path(plist_file_path)}") unless File.exist?(plist_file_path)
hash = Plist.parse_xml(plist_file_path)
UI.user_error!("Couldn't read provided plist at path #{File.expand_path(plist_file_path)}") if hash.nil?
# Convert keys to symbols
Gym.config[:export_options] = keys_to_symbols(hash)
end

def self.keys_to_symbols(hash)
# Convert keys to symbols
hash = hash.each_with_object({}) do |(k, v), memo|
memo[k.b.to_s.to_sym] = v
memo
end
hash
end
end
end
22 changes: 1 addition & 21 deletions gym/lib/gym/generators/package_command_generator_xcode7.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,10 @@ def normalize_export_options(hash)
hash
end

def keys_to_symbols(hash)
# Convert keys to symbols
hash = hash.each_with_object({}) do |(k, v), memo|
memo[k.b.to_s.to_sym] = v
memo
end
hash
end

def read_export_options
# Reads export options
if Gym.config[:export_options]
if Gym.config[:export_options].kind_of?(Hash)
# Reads options from hash
hash = normalize_export_options(Gym.config[:export_options])
else
# Reads options from file
plist_file_path = Gym.config[:export_options]
UI.user_error!("Couldn't find plist file at path #{File.expand_path(plist_file_path)}") unless File.exist?(plist_file_path)
hash = Plist.parse_xml(plist_file_path)
UI.user_error!("Couldn't read provided plist at path #{File.expand_path(plist_file_path)}") if hash.nil?
# Convert keys to symbols
hash = keys_to_symbols(hash)
end
hash = normalize_export_options(Gym.config[:export_options])

# Saves configuration for later use
Gym.config[:export_method] ||= hash[:method] || DEFAULT_EXPORT_METHOD
Expand Down

0 comments on commit 70a95b0

Please sign in to comment.