Class: Swiftproj::AddSystemFrameworkCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/swiftproj/commands/add_system_framework_command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#command_class, command_name, #get_command, help_message, #initialize, #parse_options

Constructor Details

This class inherits a constructor from Swiftproj::Command

Class Method Details

.descriptionObject



5
6
7
# File 'lib/swiftproj/commands/add_system_framework_command.rb', line 5

def self.description()
  return "Adds a system framework to an existing target"
end

.optionsObject



9
10
11
12
13
14
15
# File 'lib/swiftproj/commands/add_system_framework_command.rb', line 9

def self.options()
  return {
    "--project" => "A xcodeproj path (e.g. ReactorKit.xcodeproj)",
    "--target" => "A target name",
    "--framework" => "A framework path to be added (e.g. Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework)",
  }
end

Instance Method Details

#run(options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/swiftproj/commands/add_system_framework_command.rb', line 17

def run(options)
  project_path = options["--project"]
  target_name = options["--target"]
  framework_path = options["--framework"]

  if project_path.nil?
    raise Swiftproj::MissingArgumentError.new("--project")
  end
  if target_name.nil?
    raise Swiftproj::MissingArgumentError.new("--target")
  end
  if framework_path.nil?
    raise Swiftproj::MissingArgumentError.new("--framework")
  end

  begin
    project = @project_class.open(project_path)
  rescue
    raise Swiftproj::NoSuchFileError.new(project_path)
  end

  @core.add_system_framework(project, target_name, framework_path)
end