Method: RunLoop::Instruments#templates

Defined in:
lib/run_loop/instruments.rb

#templatesArray<String>

Returns an array of Instruments.app templates.

Depending on the Xcode version Instruments.app templates will either be:

  • A full path to the template. # Xcode 5 and Xcode > 5 betas

  • The name of a template. # Xcode >= 6 (non beta)

Maintainers! The rules above are important and explain why we can’t simply filter by ‘~= /tracetemplate/`.

Templates that users have saved will always be full paths - regardless of the Xcode version.

Returns:

  • (Array<String>)

    Instruments.app templates.



196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/run_loop/instruments.rb', line 196

def templates
  @instruments_templates ||= lambda do
    args = ['instruments', '-s', 'templates']
    hash = xcrun.run_command_in_context(args, log_cmd: true)
    hash[:out].chomp.split("\n").map do |elm|
      stripped = elm.strip.tr('"', '')
      if stripped == '' || stripped == 'Known Templates:'
        nil
      else
        stripped
      end
    end.compact
  end.call
end