class Xcake::Xcode::SchemeList

This class is used to represent a list of Schemes.

Attributes

project[RW]

@return [Project] the project for the scheme list

schemes[RW]

@return [Array<Scheme>] the schemes in the list

xcschememanagement[RW]

@return [Hash<String, Object>] xcschememanagementfile contents

Public Class Methods

new(project) click to toggle source

@param [Project] project

project to create scheme list for.
# File lib/xcake/xcode/scheme_list.rb, line 24
def initialize(project)
  @project = project
  @schemes = []

  @xcschememanagement = {
    'SchemeUserState' => {},
    'SuppressBuildableAutocreation' => {}
  }
end

Public Instance Methods

save() click to toggle source

Writes scheme list data.

# File lib/xcake/xcode/scheme_list.rb, line 46
def save
  schemes_dir = Scheme.user_data_dir(@project.path)

  FileUtils.rm_rf(schemes_dir)
  FileUtils.mkdir_p(schemes_dir)

  schemes.each do |s|
    s.save_as(@project.path, s.name, true)

    @xcschememanagement['SchemeUserState']["#{s.name}.xcscheme_^#shared#^_"] = {
      'isShown' => true
    }
  end

  xcschememanagement_path = schemes_dir + 'xcschememanagement.plist'
  write_plist(xcschememanagement_path)
end
supress_autocreation_of_target(target) click to toggle source

Adds target to add instructions to tell xcode not to autocreate scheme for target

@param [Target] target

target to supress autocreation for
# File lib/xcake/xcode/scheme_list.rb, line 40
def supress_autocreation_of_target(target)
  @xcschememanagement['SuppressBuildableAutocreation'][target.uuid] = { 'primary' => true }
end

Private Instance Methods

write_plist(xcschememanagement_path) click to toggle source
# File lib/xcake/xcode/scheme_list.rb, line 66
def write_plist(xcschememanagement_path)
  if Xcake.modern_xcodeproj?
    Xcodeproj::Plist.write_to_path(@xcschememanagement, xcschememanagement_path)
  else
    Xcodeproj.write_plist(@xcschememanagement, xcschememanagement_path)
  end
end