class Swiftproj::ConfigureSchemeCommand

Public Class Methods

description() click to toggle source
# File lib/swiftproj/commands/configure_scheme_command.rb, line 5
def self.description()
  return "Configures a scheme to have buildable targets only"
end
options() click to toggle source
# File lib/swiftproj/commands/configure_scheme_command.rb, line 9
def self.options()
  return {
    "--project" => "A xcodeproj path (e.g. ReactorKit.xcodeproj)",
    "--scheme" => "A scheme name",
    "--buildable-targets" => "Names for buildable target, seprated by comma (e.g. URLNavigator,URLMatcher)",
  }
end

Public Instance Methods

run(options) click to toggle source
# File lib/swiftproj/commands/configure_scheme_command.rb, line 17
def run(options)
  project_path = options["--project"]
  scheme_name = options["--scheme"]
  buildable_target_names = options["--buildable-targets"]

  if project_path.nil?
    raise Swiftproj::MissingArgumentError.new("--project")
  end
  if scheme_name.nil?
    raise Swiftproj::MissingArgumentError.new("--scheme")
  end
  if buildable_target_names.nil?
    raise Swiftproj::MissingArgumentError.new("--buildable-targets")
  end

  path = "#{project_path}/xcshareddata/xcschemes/#{scheme_name}.xcscheme"
  begin
    scheme = @scheme_class.new(path)
  rescue
    raise Swiftproj::NoSuchFileError.new(project_path)
  end

  target_names = buildable_target_names.split(",")
  @core.configure_scheme_with_buildable_targets(scheme, target_names)
end