@@ -15,12 +15,30 @@ module VersionHelper
1515
1616 # Returns the public-facing version string.
1717 #
18+ # @param [String] xcconfig_file The path for the .xcconfig file containing the public-facing version
19+ #
1820 # @return [String] The public-facing version number, extracted from the VERSION_LONG entry of the xcconfig file.
1921 # - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string
2022 # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number
2123 #
24+ def self . get_xcconfig_public_version ( xcconfig_file :)
25+ version = read_long_version_from_config_file ( xcconfig_file )
26+ vp = get_version_parts ( version )
27+ return "#{ vp [ MAJOR_NUMBER ] } .#{ vp [ MINOR_NUMBER ] } " unless is_hotfix? ( version )
28+
29+ "#{ vp [ MAJOR_NUMBER ] } .#{ vp [ MINOR_NUMBER ] } .#{ vp [ HOTFIX_NUMBER ] } "
30+ end
31+
32+ # Returns the public-facing version string.
33+ #
34+ # @return [String] The public-facing version number, extracted from the VERSION_LONG entry of the xcconfig file.
35+ # - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string
36+ # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number
37+ #
38+ # @deprecated This method is going to be removed soon due to it's dependency on `ENV['PUBLIC_CONFIG_FILE']` via `get_build_version`.
39+ #
2240 def self . get_public_version
23- version = get_build_version
41+ version = get_build_version ( )
2442 vp = get_version_parts ( version )
2543 return "#{ vp [ MAJOR_NUMBER ] } .#{ vp [ MINOR_NUMBER ] } " unless is_hotfix? ( version )
2644
@@ -169,15 +187,17 @@ def self.is_hotfix?(version)
169187 # @return [String] The current version according to the public xcconfig file.
170188 #
171189 def self . get_build_version
172- versions = get_version_strings ( ) [ 0 ]
190+ xcconfig_file = ENV [ 'PUBLIC_CONFIG_FILE' ]
191+ read_long_version_from_config_file ( xcconfig_file )
173192 end
174193
175194 # Returns the current value of the `VERSION_LONG` key from the internal xcconfig file
176195 #
177196 # @return [String] The current version according to the internal xcconfig file.
178197 #
179198 def self . get_internal_version
180- get_version_strings ( ) [ 1 ]
199+ xcconfig_file = ENV [ 'INTERNAL_CONFIG_FILE' ]
200+ read_long_version_from_config_file ( xcconfig_file )
181201 end
182202
183203 # Prints the current and next release version numbers to stdout, then return the next release version
@@ -301,22 +321,6 @@ def self.read_from_config_file(key, filePath)
301321 return nil
302322 end
303323
304- # Read the version numbers from the xcconfig file
305- #
306- # @env PUBLIC_CONFIG_FILE The path to the xcconfig file containing the public version numbers.
307- # @env INTERNAL_CONFIG_FILE The path to the xcconfig file containing the internal version numbers. Can be nil.
308- #
309- # @return [String] Array of long version strings found.
310- # The first element is always present and contains the version extracted from the public config file
311- # The second element is the version extracted from the internal config file, only present if one was provided.
312- def self . get_version_strings
313- version_strings = [ ]
314- version_strings << read_long_version_from_config_file ( ENV [ 'PUBLIC_CONFIG_FILE' ] )
315- version_strings << read_long_version_from_config_file ( ENV [ 'INTERNAL_CONFIG_FILE' ] ) unless ENV [ 'INTERNAL_CONFIG_FILE' ] . nil?
316-
317- return version_strings
318- end
319-
320324 # Ensure that the version provided is only composed of number parts and return the validated string
321325 #
322326 # @param [String] version The version string to validate
0 commit comments