class SimCtl::DeviceSettings

Attributes

path[R]

Public Class Methods

new(path) click to toggle source
# File lib/simctl/device_settings.rb, line 7
def initialize(path)
  @path = path
end

Public Instance Methods

disable_keyboard_helpers() click to toggle source

Disables the keyboard helpers

@return [void]

# File lib/simctl/device_settings.rb, line 14
def disable_keyboard_helpers
  edit_plist(path.preferences_plist) do |plist|
    plist['DidShowContinuousPathIntroduction'] = true
    %w[
      KeyboardAllowPaddle
      KeyboardAssistant
      KeyboardAutocapitalization
      KeyboardAutocorrection
      KeyboardCapsLock
      KeyboardCheckSpelling
      KeyboardPeriodShortcut
      KeyboardPrediction
      KeyboardShowPredictionBar
    ].each do |key|
      plist[key] = false
    end
  end
end
edit_plist(path) { |content| ... } click to toggle source
# File lib/simctl/device_settings.rb, line 43
def edit_plist(path)
  plist = File.exist?(path) ? CFPropertyList::List.new(file: path) : CFPropertyList::List.new
  content = CFPropertyList.native_types(plist.value) || {}
  yield content
  plist.value = CFPropertyList.guess(content)
  plist.save(path, CFPropertyList::List::FORMAT_BINARY)
end
set_language(language) click to toggle source

Sets the device language

@return [void]

# File lib/simctl/device_settings.rb, line 54
def set_language(language)
  edit_plist(path.global_preferences_plist) do |plist|
    key = 'AppleLanguages'
    plist[key] = [] unless plist.key?(key)
    plist[key].unshift(language).uniq!
  end
end
set_locale(locale) click to toggle source

Sets the device locale

@return [void]

# File lib/simctl/device_settings.rb, line 65
def set_locale(locale)
  edit_plist(path.global_preferences_plist) do |plist|
    plist['AppleLocale'] = locale
  end
end
update_hardware_keyboard(enabled) click to toggle source

Updates hardware keyboard settings

@param enabled value to replace @return [vod]

# File lib/simctl/device_settings.rb, line 37
def update_hardware_keyboard(enabled)
  edit_plist(path.preferences_plist) do |plist|
    plist['AutomaticMinimizationEnabled'] = enabled
  end
end