If a new Apple ID account doesn't accept Developer Agreement at https://developer.apple.com/ then Xcode download will fail with Unauthorized error
However, the way Apple handles unauthorized errors is by redirecting to https://developer.apple.com/unauthorized/ and happily returning 200. Therefore the only way to check for authorization is to catch this redirect. If we don't do this, then unauthorized html will be downloaded and attempted to be unxipped, so the xcodes will fail with a "corrupted xip" error.
Therefore this PR:
Attempts to catch unauthorized redirect and throw error
Adds a descriptive message when this error is thrown
Prevents retries in case of 403. Retrying won't help, so it's better to terminate early
How to test:
In the XcodeInstaller.swift replace all instances of sessionService.loginIfNeeded() with Promise()
xcodes signout
Try to download e.g. xcodes install 14.0
Before the change you would get "corrupted xip message", after the change you would get a nice descriptive message.
It's all very hacky, I would love to hear suggestions on how to improve the PR
If a new Apple ID account doesn't accept Developer Agreement at https://developer.apple.com/ then Xcode download will fail with Unauthorized error
However, the way Apple handles unauthorized errors is by redirecting to https://developer.apple.com/unauthorized/ and happily returning 200. Therefore the only way to check for authorization is to catch this redirect. If we don't do this, then unauthorized html will be downloaded and attempted to be unxipped, so the xcodes will fail with a "corrupted xip" error.
Therefore this PR:
How to test:
XcodeInstaller.swift
replace all instances ofsessionService.loginIfNeeded()
withPromise()
xcodes signout
xcodes install 14.0
Before the change you would get "corrupted xip message", after the change you would get a nice descriptive message.
It's all very hacky, I would love to hear suggestions on how to improve the PR