Description
Hello
This issue was described in several tickets but solution is still not there.
There are several third-party libraries that swizzle URLSession
's delegate
with their own proxy objects. For example TrustKit and SplunkMint do that. However GTMSessionFetcherService
completely ignores this fact and hard-casts these proxy objects to its own class - GTMSessionFetcherSessionDelegateDispatcher
:
BOOL hasDispatcher = (fetcherDelegate != nil &&
![fetcherDelegate isKindOfClass:[GTMSessionFetcher class]]);
if (hasDispatcher) {
GTMSESSION_ASSERT_DEBUG([fetcherDelegate isKindOfClass:[GTMSessionFetcherSessionDelegateDispatcher class]],
@"Fetcher delegate class: %@", [fetcherDelegate class]);
return (GTMSessionFetcherSessionDelegateDispatcher *)fetcherDelegate;
}
Obviously later we get crashes in different places due to "unrecognized selector sent to instance" exceptions.
The "dumb" solution is to check the class of object before casting it:
if ([fetcherDelegate isKindOfClass:[GTMSessionFetcherSessionDelegateDispatcher class]]) {
return (GTMSessionFetcherSessionDelegateDispatcher *)fetcherDelegate;
}
else {
return nil;
}
But having almost zero knowledge of how GTMSessionFetcher works, it's hard for me to understand if this code breaks something else. Any advice from the team?
We consume this library indirectly via FirebaseAuth.
Thanks,
Vlad