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

Add support for Apple API sessions from Fastlane Spaceship #257

Closed adamprice closed 1 year ago

adamprice commented 1 year ago

As I use fastlane and xcodes, I thought it could be cool if xcodes could use the same Apple API auth session as fastlane to avoid having to authenticate twice.

I've added two new command line options:

--use-fastlane-auth # enable/disable feature, default off
--fastlane-user # fastlane spaceship user, uses FASTLANE_SESSION env var if none provided

With this mode enabled, cookies are copied from either the FASTLANE_SESSION environment variable or ~/.fastlane/spaceship/<user>/cookie file into an ephemeral URLSessionConfiguration that's then used for creating a URLSession to send requests. It also works with the way cookies are copied into the request for aria2. Hopefully this should stop the cookies from conficting with any existing sessions present in xcodes and they wont persist after the application has exited.

The current implementation is obviously coupled with how fastlane handles its cookies. As there's also a fastlane action for xcodes (https://docs.fastlane.tools/actions/xcodes/), another option could be coming up with a tool agnostic format for the cookies that the fastlane action can provide to xcodes.

tahirmt commented 1 year ago

This is such a great idea! Something I tinkered with in the past but used ruby to achieve it. I do hope this gets in.

adamprice commented 1 year ago

I'll update in the next couple of days and then remove the draft status.

ykhandelwal913 commented 1 year ago

@adamprice @tahirmt Is this ready for merge? This will solve the issue with CI environment

ykhandelwal913 commented 1 year ago

@MattKiazyk can you please review this. This is very much needed as we are planning to migrate from xcversion to xcodes in our ci environment. xcodes seems to be very fast.

MattKiazyk commented 1 year ago

@ykhandelwal913 I'll try to find some time this weekend to get it through. Sorry for the delay

ykhandelwal913 commented 1 year ago

@MattKiazyk thanks for looking into it. Are you planning to merge and release a new version of xcodes or it this waiting for some other change?

ykhandelwal913 commented 1 year ago

@MattKiazyk @adamprice can that be merged?

ykhandelwal913 commented 1 year ago

@MattKiazyk we have a big dependency on fastlane session to migrate to xcodes. Can this PR request be merge if all checks are ok?

MattKiazyk commented 1 year ago

Thanks @adamprice for all the work!

@ykhandelwal913 this will be in the next version. However, I don't have a specific timeline on when that will be.