Class: Xcode::Scheme

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/scheme.rb

Overview

Schemes are an XML file that describe build, test, launch and profile actions For the purposes of Xcoder, we want to be able to build and test The scheme’s build action only describes a target, so we need to look at launch for the config

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Scheme

Returns a new instance of Scheme.



10
11
12
13
14
15
16
17
18
# File 'lib/xcode/scheme.rb', line 10

def initialize(path)
  @path = File.expand_path(path)
  @root = File.expand_path "#{@path}/../../../../"
  @name = File.basename(path).gsub(/\.xcscheme$/,'')
  doc = Nokogiri::XML(open(@path))
  
  @launch = parse_action(doc, 'launch')
  @test = parse_action(doc, 'test')
end

Instance Attribute Details

#launchObject (readonly)

Returns the value of attribute launch.



9
10
11
# File 'lib/xcode/scheme.rb', line 9

def launch
  @launch
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/xcode/scheme.rb', line 9

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



9
10
11
# File 'lib/xcode/scheme.rb', line 9

def path
  @path
end

#testObject (readonly)

Returns the value of attribute test.



9
10
11
# File 'lib/xcode/scheme.rb', line 9

def test
  @test
end

Class Method Details

.find_in_path(path) ⇒ Array<Scheme>

Parse all the scheme files that can be found in the given project or workspace. Schemes can be defined as shared schemes and then user specific schemes. Parsing the schemes will load the shared ones and then the current acting user’s schemes.

Returns:

  • (Array<Scheme>)

    the shared schemes and user specific schemes found within the projet/workspace at the path defined for schemes.



37
38
39
40
41
42
43
44
# File 'lib/xcode/scheme.rb', line 37

def self.find_in_path(path)
  shared_schemes = Dir["#{path}/xcshareddata/xcschemes/*.xcscheme"]
  user_specific_schemes = Dir["#{path}/xcuserdata/#{ENV['USER']}.xcuserdatad/xcschemes/*.xcscheme"]
  
  (shared_schemes + user_specific_schemes).map do |scheme|
    Xcode::Scheme.new(scheme)
  end
end

Instance Method Details

#builderObject

def project

launch.target.project

end



24
25
26
# File 'lib/xcode/scheme.rb', line 24

def builder
  Xcode::Builder.new(self)
end