Class: Fastlane::Wpmreleasetoolkit::Versioning::IOSVersionFile
- Inherits:
-
Object
- Object
- Fastlane::Wpmreleasetoolkit::Versioning::IOSVersionFile
- Defined in:
- lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb
Overview
The ‘IOSVersionFile` class takes in an .xcconfig file path and reads/writes values to/from the file.
Instance Attribute Summary collapse
-
#xcconfig_path ⇒ Object
readonly
Returns the value of attribute xcconfig_path.
Instance Method Summary collapse
-
#initialize(xcconfig_path:) ⇒ IOSVersionFile
constructor
Initializes a new instance of IOSVersionFile with the specified .xcconfig file path.
-
#read_build_code(attribute_name:) ⇒ String
Reads the build code from the .xcconfig file and returns it String.
-
#read_release_version ⇒ String
Reads the release version from the .xcconfig file and returns it as a String.
-
#write(version_short: nil, version_long: nil, build_number: nil) ⇒ Object
Writes the provided version numbers to the .xcconfig file.
Constructor Details
#initialize(xcconfig_path:) ⇒ IOSVersionFile
Initializes a new instance of IOSVersionFile with the specified .xcconfig file path.
14 15 16 17 18 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb', line 14 def initialize(xcconfig_path:) UI.user_error!(".xcconfig file not found at this path: #{xcconfig_path}") unless File.exist?(xcconfig_path) @xcconfig_path = xcconfig_path end |
Instance Attribute Details
#xcconfig_path ⇒ Object (readonly)
Returns the value of attribute xcconfig_path.
8 9 10 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb', line 8 def xcconfig_path @xcconfig_path end |
Instance Method Details
#read_build_code(attribute_name:) ⇒ String
Reads the build code from the .xcconfig file and returns it String.
Some apps store the build code in the VERSION_LONG attribute, while others store it in the BUILD_NUMBER attribute.
37 38 39 40 41 42 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb', line 37 def read_build_code(attribute_name:) UI.user_error!('attribute_name must be `VERSION_LONG` or `BUILD_NUMBER`') unless attribute_name.eql?('VERSION_LONG') || attribute_name.eql?('BUILD_NUMBER') config = Xcodeproj::Config.new(xcconfig_path) config.attributes[attribute_name] end |
#read_release_version ⇒ String
Reads the release version from the .xcconfig file and returns it as a String.
24 25 26 27 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb', line 24 def read_release_version config = Xcodeproj::Config.new(xcconfig_path) config.attributes['VERSION_SHORT'] end |
#write(version_short: nil, version_long: nil, build_number: nil) ⇒ Object
Writes the provided version numbers to the .xcconfig file.
version_long is optional because there are times when it won’t be updated, such as a new beta build. version_short is optional because some apps (such as Day One iOS/Mac or Simplenote Mac) don’t use it. build_number is optional because some apps (such as WP/JP iOS or WCiOS) don’t use it.
54 55 56 57 58 59 60 |
# File 'lib/fastlane/plugin/wpmreleasetoolkit/versioning/files/ios_version_file.rb', line 54 def write(version_short: nil, version_long: nil, build_number: nil) config = Xcodeproj::Config.new(xcconfig_path) config.attributes['VERSION_SHORT'] = version_short.to_s unless version_short.nil? config.attributes['VERSION_LONG'] = version_long.to_s unless version_long.nil? config.attributes['BUILD_NUMBER'] = build_number.to_s unless build_number.nil? config.save_as(Pathname.new(xcconfig_path)) end |