kean / Pulse

Network logger for Apple platforms

Home Page:https://pulselogger.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

URLSessionProxyDelegate.enableAutomaticRegistration swizzling troubles with Instabug SDK

jgodonQobuz opened this issue · comments

Hi !

I hope you're doing well 👍

I'm using your great library with the new macOS app that is very useful to us to monitor network calls and speed troubles of our app across the world.

Unfortunately, I'm experimenting conflicts between Pulse lib and Instabug lib... Instabug bugs reporter seems to be swizzled by Pulse... As we're using both in our project this is very sad because we've to choose between user feature bugs reporting and network log monitoring...

I'll let guys from Instabug come to you with more details but I think this is the function at the origin of this issue :

public extension URLSessionProxyDelegate {
    /// Enables automatic registration of `URLSessionProxyDelegate`. After calling this method, every time
    /// you initialize a `URLSession` using `init(configuration:delegate:delegateQueue:))` method, the
    /// delegate will automatically get replaced with a `URLSessionProxyDelegate` that logs all the
    /// needed events and forwards the methods to your original delegate.
    static func enableAutomaticRegistration(logger: NetworkLogger = .init()) {
        sharedLogger = logger
        if let lhs = class_getClassMethod(URLSession.self, #selector(URLSession.init(configuration:delegate:delegateQueue:))),
           let rhs = class_getClassMethod(URLSession.self, #selector(URLSession.pulse_init(configuration:delegate:delegateQueue:))) {
            method_exchangeImplementations(lhs, rhs)
        }
    }
}

I hope a solution will be found because these two tools are so great !

Best wishes

Jeremie

There are multiple ways to integrate Pulse, ranging from some to no swizzling required. Please consider using a different approach.