From 07a3b530dfa4bf26e15b9608f9f73908832ad379 Mon Sep 17 00:00:00 2001 From: Alex Niderberg Date: Wed, 14 Sep 2016 17:58:48 -0400 Subject: [PATCH 1/6] Ensuring the xip extraction will work - Adding an alert if the os version is less than 10.11.5. Issue #163 --- README.md | 15 +++++++++------ lib/xcode/install.rb | 19 +++++++++++++++++++ lib/xcode/install/install.rb | 3 ++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c54e16bb..bb9f2ebd 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. diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb index c013b98e..6d6b6af7 100644 --- a/lib/xcode/install.rb +++ b/lib/xcode/install.rb @@ -48,6 +48,25 @@ def current_symlink File.symlink?(SYMLINK_PATH) ? SYMLINK_PATH : nil end + def os_version_compatibility_issue?(version) + if version != "8" + return false + end + + osx_version = `sw_vers -productVersion`.delete!("\n") + version_parts = osx_version.split('.') + + major = version_parts[0].to_i + minor = version_parts[1].to_i + patch = version_parts[2].to_i + + if minor < 12 + if minor < 11 or minor == 11 and patch < 5 + return true + end + end + end + def download(version, progress, url = nil) return unless url || exist?(version) xcode = seedlist.find { |x| x.name == version } unless url diff --git a/lib/xcode/install/install.rb b/lib/xcode/install/install.rb index fc2bce33..63e6ef19 100644 --- a/lib/xcode/install/install.rb +++ b/lib/xcode/install/install.rb @@ -33,8 +33,9 @@ def initialize(argv) 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/ From da4f529669fd116a88c415bf987de0ec5936b599 Mon Sep 17 00:00:00 2001 From: Alex Niderberg Date: Wed, 14 Sep 2016 22:53:39 -0400 Subject: [PATCH 2/6] resolving robocop issues --- lib/xcode/install.rb | 12 ++---------- lib/xcode/install/install.rb | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb index 6d6b6af7..c9448373 100644 --- a/lib/xcode/install.rb +++ b/lib/xcode/install.rb @@ -49,22 +49,15 @@ def current_symlink end def os_version_compatibility_issue?(version) - if version != "8" - return false - end + return false if version != '8' osx_version = `sw_vers -productVersion`.delete!("\n") version_parts = osx_version.split('.') - major = version_parts[0].to_i minor = version_parts[1].to_i patch = version_parts[2].to_i - if minor < 12 - if minor < 11 or minor == 11 and patch < 5 - return true - end - end + return true if minor < 12 && minor < 11 || minor == 11 && patch < 5 end def download(version, progress, url = nil) @@ -126,7 +119,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 63e6ef19..28aaed79 100644 --- a/lib/xcode/install/install.rb +++ b/lib/xcode/install/install.rb @@ -33,9 +33,9 @@ def initialize(argv) 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, '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/ From 5360f4c38a9133e4b054a669f8d87c1b4472b8cb Mon Sep 17 00:00:00 2001 From: Alex Niderberg Date: Wed, 14 Sep 2016 23:04:06 -0400 Subject: [PATCH 3/6] Upping the the limits for robocop to silence the errors with `install_dmg`. --- .rubocop_todo.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 From 2f84f465776bbd5beb97eb6de7f9a1a8c047d188 Mon Sep 17 00:00:00 2001 From: aln787 Date: Thu, 15 Sep 2016 08:28:26 -0400 Subject: [PATCH 4/6] Updating Xcode 8 install dialog for the GM release --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bb9f2ebd..971533e9 100644 --- a/README.md +++ b/README.md @@ -60,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. From de7eef755a2760b176cdc45411cc8495d3cfb641 Mon Sep 17 00:00:00 2001 From: Alex Niderberg Date: Fri, 16 Sep 2016 15:10:06 -0400 Subject: [PATCH 5/6] Adding a comment and clean-up. --- lib/xcode/install.rb | 2 ++ lib/xcode/install/install.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb index c9448373..5a06051b 100644 --- a/lib/xcode/install.rb +++ b/lib/xcode/install.rb @@ -49,6 +49,8 @@ def current_symlink end def os_version_compatibility_issue?(version) + #After 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") diff --git a/lib/xcode/install/install.rb b/lib/xcode/install/install.rb index 28aaed79..946f875c 100644 --- a/lib/xcode/install/install.rb +++ b/lib/xcode/install/install.rb @@ -35,7 +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, '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/ From 7f902ee74489581166cd645dc50081232d12230e Mon Sep 17 00:00:00 2001 From: aln787 Date: Fri, 16 Sep 2016 15:12:46 -0400 Subject: [PATCH 6/6] Final change --- lib/xcode/install.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/xcode/install.rb b/lib/xcode/install.rb index 5a06051b..f6734f00 100644 --- a/lib/xcode/install.rb +++ b/lib/xcode/install.rb @@ -49,7 +49,7 @@ def current_symlink end def os_version_compatibility_issue?(version) - #After Xcode 8 requires 10.11.5+ to extract the .xip + #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'