Skip to content

Commit 0c497cd

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

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

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
@@ -299,21 +301,10 @@ def self.read_build_number_from_config_file(file_path)
299301
# @return [String] The value for the given key, or `nil` if the key was not found.
300302
#
301303
def self.read_from_config_file(key, file_path)
302-
UI.user_error!("File #{file_path} not found") unless File.exist?(file_path)
303-
304-
File.open(file_path, 'r') do |f|
305-
f.each_line do |line|
306-
line.strip!
307-
next if line.nil? || line.empty?
308-
309-
key_value = line.split(/\s*=\s*/)
310-
if key_value[0].strip() == key
311-
return key_value[1].strip()
312-
end
313-
end
314-
end
304+
UI.user_error!(".xcconfig file #{file_path} not found") unless File.exist?(file_path)
315305

316-
return nil
306+
config = Xcodeproj::Config.new(file_path)
307+
config.attributes[key]
317308
end
318309

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

0 commit comments

Comments
 (0)