Class: Yolo::Tools::Ios::Xcode

Inherits:
Object
  • Object
show all
Defined in:
lib/yolo/tools/ios/xcode.rb

Overview

Provides an interface to Xcode

Author:

  • Alex Fish

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info_plist_path = "") ⇒ Xcode

Creates a new instance of Xcode with the default preferences p list location loaded

Parameters:

  • info_plist_path (String) (defaults to: "")

    The full path to an xcode projects info_plist



22
23
24
25
# File 'lib/yolo/tools/ios/xcode.rb', line 22

def initialize(info_plist_path = "")
  self.prefs_plist_path = "#{File.expand_path('~')}/Library/Preferences/com.apple.dt.Xcode.plist"
  self.info_plist_path = info_plist_path
end

Instance Attribute Details

#info_plist_pathObject

The path to an applications info plist



15
16
17
# File 'lib/yolo/tools/ios/xcode.rb', line 15

def info_plist_path
  @info_plist_path
end

#prefs_plist_pathObject

The path to The Xcode preferences file



13
14
15
# File 'lib/yolo/tools/ios/xcode.rb', line 13

def prefs_plist_path
  @prefs_plist_path
end

Instance Method Details

#build_numberString

Queries the instances info_plist hash to return the CFBundleVersion

Returns:

  • (String)

    The current instances info.plist CFBundleVersion



64
65
66
# File 'lib/yolo/tools/ios/xcode.rb', line 64

def build_number
  info_plist["CFBundleVersion"]
end

#build_pathString

Querys Xcode’s preferences to find it’s build folder location

Returns:

  • (String)

    The full path to Xcode’s build location



40
41
42
43
44
# File 'lib/yolo/tools/ios/xcode.rb', line 40

def build_path
  path = prefs["IDECustomDerivedDataLocation"]
  path = "#{File.expand_path('~')}/Library/Developer/Xcode/DerivedData" unless path
  path
end

#info_plistHash

Creates a Hash representation of an applications info.plist

Returns:

  • (Hash)

    A hash representation of the instances info.plist



50
51
52
53
54
55
56
57
58
# File 'lib/yolo/tools/ios/xcode.rb', line 50

def info_plist
  if info_plist_path
    plist = CFPropertyList::List.new(:file => info_plist_path)
    CFPropertyList.native_types(plist.value)
  else
    error = Yolo::Formatters::ErrorFormatter.new
    error.info_plist_not_found
  end
end

#prefsHash

Returns a hash representation of Xcode’s preferences

Returns:

  • (Hash)

    A hash containing all of Xcode’s preferences



31
32
33
34
# File 'lib/yolo/tools/ios/xcode.rb', line 31

def prefs
  plist = CFPropertyList::List.new(:file => prefs_plist_path)
  CFPropertyList.native_types(plist.value)
end

#version_numberString

Queries the instances info_plist hash to return the CFBundleShortVersionString

Returns:

  • (String)

    The current instances info.plist CFBundleShortVersionString



72
73
74
# File 'lib/yolo/tools/ios/xcode.rb', line 72

def version_number
  info_plist["CFBundleShortVersionString"]
end