class FastlaneExt::ProjectController

Public Class Methods

new(path, schemes) click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 9
def initialize(path, schemes)
  raise 'Invalid Path' unless File.directory?(path)

  @project = Xcodeproj::Project.open(path)
  @schemes = schemes
end

Public Instance Methods

build_version() click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 39
def build_version
  value = scheme_value_for_key(@schemes.first, build_version_key)
  Version.new(value)
end
bump_build_version_patch() click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 16
def bump_build_version_patch
  value = build_version.to_s
  value[-1] = (value[-1].to_i + 1).to_s
  set_build_version(Version.new(value))
end
set_build_version(version) click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 28
def set_build_version(version)
  @schemes.each do |s|
    set_scheme_value_for_key(s, version.to_s, build_version_key)
  end
end
set_version(version) click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 22
def set_version(version)
  @schemes.each do |s|
    set_scheme_value_for_key(s, version.to_s, version_key)
  end
end
version() click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 34
def version
  value = scheme_value_for_key(@schemes.first, version_key)
  Version.new(value)
end

Private Instance Methods

build_version_key() click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 78
def build_version_key
  'CURRENT_PROJECT_VERSION'
end
project_target(scheme) click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 67
def project_target(scheme)
  target = @project.targets.find { |t| t.name == scheme }
  raise "Target not found for scheme: #{scheme}" unless target

  target
end
scheme_value_for_key(scheme, key, configuration = nil) click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 55
def scheme_value_for_key(scheme, key, configuration = nil)
  target = project_target(scheme)
  target.build_configurations.each do |config|
    if configuration.nil? || config.name == configuration
      value = config.build_settings[key]
      return value if value
    end
  end

  nil
end
set_scheme_value_for_key(scheme, value, key, configuration = nil) click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 46
def set_scheme_value_for_key(scheme, value, key, configuration = nil)
  target = project_target(scheme)
  target.build_configurations.each do |config|
    config.build_settings[key] = value if configuration.nil? || config.name == configuration
  end

  @project.save
end
version_key() click to toggle source
# File lib/fastlane-ext/project_controller.rb, line 74
def version_key
  'MARKETING_VERSION'
end