Class: XcodeInstall::InstalledXcode
- Inherits:
-
Object
- Object
- XcodeInstall::InstalledXcode
- Defined in:
- lib/xcode/install.rb
Instance Attribute Summary collapse
-
#available_simulators ⇒ Object
readonly
Returns the value of attribute available_simulators.
-
#bundle_version ⇒ Object
readonly
Returns the value of attribute bundle_version.
-
#downloadable_index_url ⇒ Object
readonly
Returns the value of attribute downloadable_index_url.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #approve_license ⇒ Object
-
#fetch_version ⇒ Object
This method might take a few ms, this could be improved by implementing github.com/KrauseFx/xcode-install/issues/273.
-
#initialize(path) ⇒ InstalledXcode
constructor
A new instance of InstalledXcode.
- #install_components ⇒ Object
- #plist_entry(keypath) ⇒ Object
Constructor Details
#initialize(path) ⇒ InstalledXcode
Returns a new instance of InstalledXcode.
581 582 583 |
# File 'lib/xcode/install.rb', line 581 def initialize(path) @path = Pathname.new(path) end |
Instance Attribute Details
#available_simulators ⇒ Object (readonly)
Returns the value of attribute available_simulators.
579 580 581 |
# File 'lib/xcode/install.rb', line 579 def available_simulators @available_simulators end |
#bundle_version ⇒ Object (readonly)
Returns the value of attribute bundle_version.
576 577 578 |
# File 'lib/xcode/install.rb', line 576 def bundle_version @bundle_version end |
#downloadable_index_url ⇒ Object (readonly)
Returns the value of attribute downloadable_index_url.
578 579 580 |
# File 'lib/xcode/install.rb', line 578 def downloadable_index_url @downloadable_index_url end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
574 575 576 |
# File 'lib/xcode/install.rb', line 574 def path @path end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
577 578 579 |
# File 'lib/xcode/install.rb', line 577 def uuid @uuid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
575 576 577 |
# File 'lib/xcode/install.rb', line 575 def version @version end |
Instance Method Details
#approve_license ⇒ Object
607 608 609 610 611 612 613 614 615 616 617 618 |
# File 'lib/xcode/install.rb', line 607 def approve_license if Gem::Version.new(version) < Gem::Version.new('7.3') license_path = "#{@path}/Contents/Resources/English.lproj/License.rtf" license_id = IO.read(license_path).match(/\bEA\d{4}\b/) 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}` else `sudo #{@path}/Contents/Developer/usr/bin/xcodebuild -license accept` end end |
#fetch_version ⇒ Object
This method might take a few ms, this could be improved by implementing github.com/KrauseFx/xcode-install/issues/273
645 646 647 648 649 |
# File 'lib/xcode/install.rb', line 645 def fetch_version output = `DEVELOPER_DIR='' "#{@path}/Contents/Developer/usr/bin/xcodebuild" -version` return '0.0' if output.nil? || output.empty? # ¯\_(ツ)_/¯ output.split("\n").first.split(' ')[1] end |
#install_components ⇒ Object
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 |
# File 'lib/xcode/install.rb', line 628 def install_components # starting with Xcode 9, we have `xcodebuild -runFirstLaunch` available to do package # postinstalls using a documented option if Gem::Version.new(@version) >= Gem::Version.new('9') `sudo #{@path}/Contents/Developer/usr/bin/xcodebuild -runFirstLaunch` else Dir.glob("#{@path}/Contents/Resources/Packages/*.pkg").each do |pkg| `sudo installer -pkg #{pkg} -target /` end end 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
653 654 655 |
# File 'lib/xcode/install.rb', line 653 def plist_entry(keypath) `/usr/libexec/PlistBuddy -c "Print :#{keypath}" "#{path}/Contents/Info.plist"`.chomp end |