XcodesOrg / xcodes

The best command-line tool to install and switch between multiple versions of Xcode.
MIT License
3.6k stars 120 forks source link

Added support for fastlane auth cookies #265

Closed omarzl closed 1 year ago

omarzl commented 1 year ago

Solves issue https://github.com/RobotsAndPencils/xcodes/issues/141 Inspired by this fork commit: https://github.com/tahirmt/xcodes/commit/2da7761d34ace622044b2780b971d4c0c06b83d8

fastlane spaceauth generates a YML session string so we can parse it directly and inject those cookies into the session's cookies storage.

I kept the FASTLANE_SESSION env var name to have direct support with fastlane.

Steps

You will now be able to download Xcode in CI environments by first running locally:

fastlane spaceauth -u username@email.com

And then in your CI scripts you can export the variable and run xcodes, it won't prompt for username/password/2fa:

export  FASTLANE_SESSION='---\n-.......'
xcodes download 14.0

References: https://github.com/fastlane/fastlane/blob/master/spaceship/lib/spaceship/client.rb#L280 https://github.com/sparklemotion/http-cookie/blob/master/lib/http/cookie_jar/yaml_saver.rb#L19

tahirmt commented 1 year ago

This will close https://github.com/RobotsAndPencils/xcodes/issues/248

tahirmt commented 1 year ago

Also possible duplicate of https://github.com/RobotsAndPencils/xcodes/pull/257

omarzl commented 1 year ago

Also possible duplicate of #257

Oh there was another pr already parsing the cookie using Yams, I think we should prefer #257 instead of mine since it has a more complete solution

tahirmt commented 1 year ago

@omarzl can you close this PR if it isn't needed?

omarzl commented 1 year ago

Sure!