embrace-io / embrace-apple-sdk

Embrace's Swift SDK built on OpenTelemetry
https://embrace.io/docs/ios/
Apache License 2.0
117 stars 11 forks source link

[EMBR-5846] Fix `URLSessionDelegate` methods forwading based on `responds` and not only conformance #133

Open ArielDemarco opened 4 days ago

ArielDemarco commented 4 days ago

Overview

This PR addresses an issue where some methods from different NSURLSessionDelegate subprotocols (such as NSURLSessionDataDelegate or NSURLSessionTaskDelegate) may be implemented by the original delegate without explicitly declaring conformance to these subprotocols. Probably, this can work because Foundation likely checks whether the object responds to a selector, rather than strictly verifying if it declares conformance to the protocol.

To resolve this, our implementation now performs a similar behavior. If we detect that the original delegate does not explicitly conform to the expected subprotocol but responds to the relevant selectors, we directly forward the calls to the original delegate. This ensures compatibility with delegates that rely on runtime behavior for method resolution.

[WIP: Missing tests]

notion-workspace[bot] commented 4 days ago

Issue forwarding to NSURLSessionDelegate methods if object doesn’t conform to specific protocol

github-actions[bot] commented 4 days ago

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

github-actions[bot] commented 4 days ago
Warnings
:warning: No CHANGELOG entry added.

Generated by :no_entry_sign: Danger Swift against e782e361fe9a768b74ed339ab3b64db9c9e0ef28