@@ -15,12 +15,30 @@ module VersionHelper
15
15
16
16
# Returns the public-facing version string.
17
17
#
18
+ # @param [String] xcconfig_file The path for the .xcconfig file containing the public-facing version
19
+ #
18
20
# @return [String] The public-facing version number, extracted from the VERSION_LONG entry of the xcconfig file.
19
21
# - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string
20
22
# - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number
21
23
#
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
+ #
22
40
def self . get_public_version
23
- version = get_build_version
41
+ version = get_build_version ( )
24
42
vp = get_version_parts ( version )
25
43
return "#{ vp [ MAJOR_NUMBER ] } .#{ vp [ MINOR_NUMBER ] } " unless is_hotfix? ( version )
26
44
@@ -169,15 +187,17 @@ def self.is_hotfix?(version)
169
187
# @return [String] The current version according to the public xcconfig file.
170
188
#
171
189
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 )
173
192
end
174
193
175
194
# Returns the current value of the `VERSION_LONG` key from the internal xcconfig file
176
195
#
177
196
# @return [String] The current version according to the internal xcconfig file.
178
197
#
179
198
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 )
181
201
end
182
202
183
203
# 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)
301
321
return nil
302
322
end
303
323
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
-
320
324
# Ensure that the version provided is only composed of number parts and return the validated string
321
325
#
322
326
# @param [String] version The version string to validate
0 commit comments