Class: XcodeInstall::InstalledXcode

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/install.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ InstalledXcode

Returns a new instance of InstalledXcode.



398
399
400
# File 'lib/xcode/install.rb', line 398

def initialize(path)
  @path = Pathname.new(path)
end

Instance Attribute Details

#available_simulatorsObject (readonly)

Returns the value of attribute available_simulators.



396
397
398
# File 'lib/xcode/install.rb', line 396

def available_simulators
  @available_simulators
end

#bundle_versionObject (readonly)

Returns the value of attribute bundle_version.



393
394
395
# File 'lib/xcode/install.rb', line 393

def bundle_version
  @bundle_version
end

#downloadable_index_urlObject (readonly)

Returns the value of attribute downloadable_index_url.



395
396
397
# File 'lib/xcode/install.rb', line 395

def downloadable_index_url
  @downloadable_index_url
end

#pathObject (readonly)

Returns the value of attribute path.



391
392
393
# File 'lib/xcode/install.rb', line 391

def path
  @path
end

#uuidObject (readonly)

Returns the value of attribute uuid.



394
395
396
# File 'lib/xcode/install.rb', line 394

def uuid
  @uuid
end

#versionObject (readonly)

Returns the value of attribute version.



392
393
394
# File 'lib/xcode/install.rb', line 392

def version
  @version
end

Instance Method Details

#approve_licenseObject



418
419
420
421
422
423
424
425
# File 'lib/xcode/install.rb', line 418

def approve_license
  license_path = "#{@path}/Contents/Resources/English.lproj/License.rtf"
  license_id = IO.read(license_path).match(/^EA\d{4}/)
  license_plist_path = '/Library/Preferences/com.apple.dt.Xcode.plist'
  `sudo rm -rf #{license_plist_path}`
  `sudo /usr/libexec/PlistBuddy -c "add :IDELastGMLicenseAgreedTo string #{license_id}" #{license_plist_path}`
  `sudo /usr/libexec/PlistBuddy -c "add :IDEXcodeVersionForAgreedToGMLicense string #{@version}" #{license_plist_path}`
end

#fetch_versionObject



447
448
449
450
451
# File 'lib/xcode/install.rb', line 447

def fetch_version
  output = `DEVELOPER_DIR='' "#{@path}/Contents/Developer/usr/bin/xcodebuild" -version`
  return '0.0' if output.nil? # ¯\_(ツ)_/¯
  output.split("\n").first.split(' ')[1]
end

#install_componentsObject



433
434
435
436
437
438
439
# File 'lib/xcode/install.rb', line 433

def install_components
  `sudo installer -pkg #{@path}/Contents/Resources/Packages/MobileDevice.pkg -target /`
  osx_build_version = `sw_vers -buildVersion`.chomp
  tools_version = `/usr/libexec/PlistBuddy -c "Print :ProductBuildVersion" "#{@path}/Contents/version.plist"`.chomp
  cache_dir = `getconf DARWIN_USER_CACHE_DIR`.chomp
  `touch #{cache_dir}com.apple.dt.Xcode.InstallCheckCache_#{osx_build_version}_#{tools_version}`
end

#plist_entry(keypath) ⇒ Object



443
444
445
# File 'lib/xcode/install.rb', line 443

def plist_entry(keypath)
  `/usr/libexec/PlistBuddy -c "Print :#{keypath}" "#{path}/Contents/Info.plist"`.chomp
end