diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bd4959e6..c273ce1c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -8,21 +8,21 @@ # Offense count: 11 Metrics/AbcSize: - Max: 39 + Max: 44 # Offense count: 1 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 226 + Max: 260 # Offense count: 3 Metrics/CyclomaticComplexity: - Max: 8 + Max: 10 # Offense count: 10 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 40 + Max: 51 # Offense count: 1 # Configuration parameters: CountKeywordArgs. @@ -31,4 +31,4 @@ Metrics/ParameterLists: # Offense count: 2 Metrics/PerceivedComplexity: - Max: 9 + Max: 12 diff --git a/README.md b/README.md index c54e16bb..971533e9 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Install and update your Xcodes automatically. ``` $ gem install xcode-install -$ xcversion install 6.3 +$ xcversion install 8 ``` ## Installation @@ -35,15 +35,18 @@ XCODE_INSTALL_USER XCODE_INSTALL_PASSWORD ``` +or + +``` +FASTLANE_USER +FASTLANE_PASSWORD +``` + To list available versions: ``` $ xcversion list -6.0.1 -6.1 -6.1.1 -6.2 -6.3 +8 ``` Installed versions will be omitted and by default, only the latest major version is listed. @@ -57,12 +60,12 @@ To install a certain version, simply: ``` $ xcversion install 8 -########################################################### 82.1% ######################################################################## 100.0% -Please authenticate for Xcode installation... +/Applications/Xcode-8.app: accepted +source=Apple System -Xcode 8 -Build version 6D570 +Xcode 8.0 +Build version 8A218a ``` This will download and install that version of Xcode. It will also be automatically selected. diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb index c013b98e..f6734f00 100644 --- a/lib/xcode/install.rb +++ b/lib/xcode/install.rb @@ -48,6 +48,20 @@ def current_symlink File.symlink?(SYMLINK_PATH) ? SYMLINK_PATH : nil end + def os_version_compatibility_issue?(version) + #Xcode 8 requires 10.11.5+ to extract the .xip + #Extracting the Xcode .xip with < 10.11.5 returns this error `cpio read error: Undefined error: 0` + return false if version != '8' + + osx_version = `sw_vers -productVersion`.delete!("\n") + version_parts = osx_version.split('.') + + minor = version_parts[1].to_i + patch = version_parts[2].to_i + + return true if minor < 12 && minor < 11 || minor == 11 && patch < 5 + end + def download(version, progress, url = nil) return unless url || exist?(version) xcode = seedlist.find { |x| x.name == version } unless url @@ -107,7 +121,6 @@ def install_dmg(dmg_path, suffix = '', switch = true, clean = true) $stderr.puts out.tr("\n", ' ') return end - `sudo -p "#{prompt}" ditto "#{source}" "#{xcode_path}"` `umount "/Volumes/Xcode"` end diff --git a/lib/xcode/install/install.rb b/lib/xcode/install/install.rb index fc2bce33..946f875c 100644 --- a/lib/xcode/install/install.rb +++ b/lib/xcode/install/install.rb @@ -35,6 +35,7 @@ def validate! super help! 'A VERSION argument is required.' unless @version + fail Informative, 'An OS X version >10.11.4 is required for Xcode 8.' if @installer.os_version_compatibility_issue?(@version) fail Informative, "Version #{@version} already installed." if @installer.installed?(@version) && !@force fail Informative, "Version #{@version} doesn't exist." unless @url || @installer.exist?(@version) fail Informative, "Invalid URL: `#{@url}`" unless !@url || @url =~ /\A#{URI.regexp}\z/