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
- #appname_version ⇒ Object
- #approve_license ⇒ Object
- #bundle_version_string ⇒ 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
- #verify_app_cert ⇒ Object
- #verify_app_security_assessment ⇒ Object
- #verify_integrity ⇒ Object
Constructor Details
#initialize(path) ⇒ InstalledXcode
Returns a new instance of InstalledXcode.
621 622 623 |
# File 'lib/xcode/install.rb', line 621 def initialize(path) @path = Pathname.new(path) end |
Instance Attribute Details
#available_simulators ⇒ Object (readonly)
Returns the value of attribute available_simulators.
619 620 621 |
# File 'lib/xcode/install.rb', line 619 def available_simulators @available_simulators end |
#bundle_version ⇒ Object (readonly)
Returns the value of attribute bundle_version.
616 617 618 |
# File 'lib/xcode/install.rb', line 616 def bundle_version @bundle_version end |
#downloadable_index_url ⇒ Object (readonly)
Returns the value of attribute downloadable_index_url.
618 619 620 |
# File 'lib/xcode/install.rb', line 618 def downloadable_index_url @downloadable_index_url end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
614 615 616 |
# File 'lib/xcode/install.rb', line 614 def path @path end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
617 618 619 |
# File 'lib/xcode/install.rb', line 617 def uuid @uuid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
615 616 617 |
# File 'lib/xcode/install.rb', line 615 def version @version end |
Instance Method Details
#appname_version ⇒ Object
633 634 635 636 637 638 639 640 641 642 |
# File 'lib/xcode/install.rb', line 633 def appname_version appname = @path.basename('.app').to_s version_string = appname.split('-').last begin Gem::Version.new(version_string) rescue ArgumentError puts 'Unable to determine Xcode version from path name, installed list may not correctly identify installed betas' Gem::Version.new(nil) end end |
#approve_license ⇒ Object
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
# File 'lib/xcode/install.rb', line 658 def approve_license if Gem::Version.new(version) < Gem::Version.new('7.3') license_info_path = File.join(@path, 'Contents/Resources/LicenseInfo.plist') license_id = `/usr/libexec/PlistBuddy -c 'Print :licenseID' #{license_info_path}` license_type = `/usr/libexec/PlistBuddy -c 'Print :licenseType' #{license_info_path}` license_plist_path = '/Library/Preferences/com.apple.dt.Xcode.plist' `sudo rm -rf #{license_plist_path}` if license_type == 'GM' `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 /usr/libexec/PlistBuddy -c "add :IDELastBetaLicenseAgreedTo string #{license_id}" #{license_plist_path}` `sudo /usr/libexec/PlistBuddy -c "add :IDEXcodeVersionForAgreedToBetaLicense string #{version}" #{license_plist_path}` end else `sudo #{@path}/Contents/Developer/usr/bin/xcodebuild -license accept` end end |
#bundle_version_string ⇒ Object
714 715 716 717 718 719 720 721 |
# File 'lib/xcode/install.rb', line 714 def bundle_version_string digits = plist_entry(':DTXcode').to_i.to_s if digits.length < 3 digits.split(//).join('.') else "#{digits[0..-3]}.#{digits[-2]}.#{digits[-1]}" 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
702 703 704 705 706 |
# File 'lib/xcode/install.rb', line 702 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
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 |
# File 'lib/xcode/install.rb', line 685 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
723 724 725 |
# File 'lib/xcode/install.rb', line 723 def plist_entry(keypath) `/usr/libexec/PlistBuddy -c "Print :#{keypath}" "#{path}/Contents/Info.plist"`.chomp end |
#verify_app_cert ⇒ Object
732 733 734 735 736 737 |
# File 'lib/xcode/install.rb', line 732 def verify_app_cert Fastlane::Actions::VerifyXcodeAction.run(xcode_path: @path.to_s) true rescue false end |
#verify_app_security_assessment ⇒ Object
727 728 729 730 |
# File 'lib/xcode/install.rb', line 727 def verify_app_security_assessment puts `/usr/bin/codesign --verify --verbose #{@path}` $?.exitstatus.zero? end |
#verify_integrity ⇒ Object
708 709 710 |
# File 'lib/xcode/install.rb', line 708 def verify_integrity verify_app_security_assessment && verify_app_cert end |