Better Handling of Apple Unauthorized errors #249
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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