Method: Xcodeproj::XCScheme#save_as

Defined in:
lib/xcodeproj/scheme.rb

#save_as(project_path, name, shared = true) ⇒ void

This method returns an undefined value.

Serializes the current state of the object to a “.xcscheme” file.

Examples:

Saving a scheme

scheme.save_as('path/to/Project.xcodeproj') #=> true

Parameters:

  • project_path (String, Pathname)

    The path where the “.xcscheme” file should be stored.

  • name (String)

    The name of the scheme, to have “.xcscheme” appended.

  • shared (Boolean) (defaults to: true)

    true => if the scheme must be a shared scheme (default value) false => if the scheme must be a user scheme



314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/xcodeproj/scheme.rb', line 314

def save_as(project_path, name, shared = true)
  scheme_folder_path = if shared
                         self.class.shared_data_dir(project_path)
                       else
                         self.class.user_data_dir(project_path)
                       end
  scheme_folder_path.mkpath
  scheme_path = scheme_folder_path + "#{name}.xcscheme"
  @file_path = scheme_path
  File.open(scheme_path, 'w') do |f|
    f.write(to_s)
  end
end