xcpretty / xcode-install

🔽 Install and update your Xcodes
https://fastlane.tools
MIT License
2.59k stars 239 forks source link

Xcode 10 beta 3 download is now an XIP inside a DMG, causes `xcversion update` failure. #288

Closed americanhanko closed 6 years ago

americanhanko commented 6 years ago

Upon running xcversion update, the following failure occurs:

/Users/erichanko/.gem/ruby/2.3.0/gems/xcode-install-2.4.1/lib/xcode/install.rb:438:in `prereleases': undefined method `first' for nil:NilClass (NoMethodError)
    from /Users/erichanko/.gem/ruby/2.3.0/gems/xcode-install-2.4.1/lib/xcode/install.rb:374:in `fetch_seedlist'
    from /Users/erichanko/.gem/ruby/2.3.0/gems/xcode-install-2.4.1/lib/xcode/install.rb:199:in `seedlist'
    from /Users/erichanko/.gem/ruby/2.3.0/gems/xcode-install-2.4.1/lib/xcode/install.rb:408:in `list_versions'
    from /Users/erichanko/.gem/ruby/2.3.0/gems/xcode-install-2.4.1/lib/xcode/install.rb:300:in `list'
    from /Users/erichanko/.gem/ruby/2.3.0/gems/xcode-install-2.4.1/lib/xcode/install/update.rb:10:in `run'
    from /Users/erichanko/.gem/ruby/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
    from /Users/erichanko/.gem/ruby/2.3.0/gems/xcode-install-2.4.1/bin/xcversion:12:in `<top (required)>'
    from /Users/erichanko/.gem/ruby/2.3.0/bin/xcversion:22:in `load'
    from /Users/erichanko/.gem/ruby/2.3.0/bin/xcversion:22:in `<main>'

Line 438 in lib/xcode/install.rb:

link = body.scan(%r{<button .*"(.+?.xip)".*</button>}).first.first

As it turns out, Xcode 10 beta 3 is an XIP archive bundled in a DMG. This is different from previous versions that were hosted directly as XIP archives.

xcode10beta2 xcode10beta3
KatekovAnton commented 6 years ago

@americanhanko @KrauseFx Hi! Any ideas how to fix it properly?

I made it like this but I'm not very familiar with ruby

    link = nil
    pre_link1 = body.scan(%r{<button .*"(.+?.xip)".*</button>})
    if !pre_link1.nil?
      pre_link2 = pre_link1.first
      if !pre_link2.nil?
        link = pre_link2.first
      end 
    end
    if link.nil?
      pre_link1 = body.scan(%r{<button .*"(.+?.dmg)".*</button>})
      if !pre_link1.nil?
        pre_link2 = pre_link1.first
        if !pre_link2.nil?
          link = pre_link2.first
        end 
      end
    end