Skip to content

Commit 0aa53d7

Browse files
committed
Improve method to read .xcconfig file to use Xcodeproj::Config instead of manually parsing it
1 parent 345ea83 commit 0aa53d7

1 file changed

Lines changed: 5 additions & 14 deletions

File tree

lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'xcodeproj'
2+
13
module Fastlane
24
module Helper
35
module Ios
@@ -300,21 +302,10 @@ def self.read_build_number_from_config_file(filePath)
300302
# @return [String] The value for the given key, or `nil` if the key was not found.
301303
#
302304
def self.read_from_config_file(key, file_path)
303-
UI.user_error!("File #{file_path} not found") unless File.exist?(file_path)
304-
305-
File.open(file_path, 'r') do |f|
306-
f.each_line do |line|
307-
line.strip!
308-
next if line.nil? || line.empty?
309-
310-
key_value = line.split(/\s*=\s*/)
311-
if key_value[0].strip() == key
312-
return key_value[1].strip()
313-
end
314-
end
315-
end
305+
UI.user_error!(".xcconfig file #{file_path} not found") unless File.exist?(file_path)
316306

317-
return nil
307+
config = Xcodeproj::Config.new(file_path)
308+
config.attributes[key]
318309
end
319310

320311
# Ensure that the version provided is only composed of number parts and return the validated string

0 commit comments

Comments
 (0)