Closed SebastianBoldt closed 6 years ago
For URLSession, you should register your custom URLProtocol
class. See protocolclasses
I solved this issue by swizzling URLSessions ephemeral property with my custom implementation.
@SebastianBoldt why was swizzling necessary? Shouldn't it be possible to define the protocol classes on the sessionConfiguration
?
init() {
assetDownloader.sessionConfiguration.protocolClasses = [NetworkDelayProtocol.self]
assetDownloader.delegate = self
}
edit:
you need to redefine the sessionConfiguration
for the session to be invalidated & reinitialised.
let sessionConfiguration = URLSessionConfiguration.ephemeral
sessionConfiguration.protocolClasses = [NetworkDelayProtocol.self]
assetDownloader.sessionConfiguration = sessionConfiguration
We are currently trying to write an UI-Tests that checks if the loading indicator is visible for the user if loading takes longer than expected. We tried to register a custom URLProtocol inside the AppDelegate like so:
URLProtocol.registerClass(NetworkDelayProtocol.self)
The NetworkDelayProtocol does not do much but it should at least get asked if it canInit the Request. But for some reason the custom URLProtocol class does not receive KingFishers image requests. Does someone have any ideas whats going on here? I know that Kingfisher is using a ephemeral session configuration for requesting images, maybe it has something to do with it?