Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncompilable mock generated for NSObjectProtocol / @objc protocols #248

Open
DJBen opened this issue Nov 7, 2023 · 0 comments
Open

Uncompilable mock generated for NSObjectProtocol / @objc protocols #248

DJBen opened this issue Nov 7, 2023 · 0 comments

Comments

@DJBen
Copy link

DJBen commented Nov 7, 2023

I wonder if there's a specific reason that @objc protocols are not supported?

/// @mockable(history: performRequest = true)
@objc public protocol SCCrashLoggerNetworkExecuting: NSObjectProtocol {
    @objc func performRequest(
        request: URLRequest,
        reportId: String,
        includeLogs: Bool,
        onSuccess: @escaping () -> Void,
        onPermanentFailure: @escaping (Error, String) -> Void
    ) -> String
}

Generated source:

import Foundation


public class SCCrashLoggerNetworkExecutingMock: SCCrashLoggerNetworkExecuting {
    public init() { }


    public private(set) var performRequestCallCount = 0
    public var performRequestArgValues = [(URLRequest, String, Bool)]()
    public var performRequestHandler: ((URLRequest, String, Bool, @escaping () -> Void, @escaping (Error, String) -> Void) -> (String))?
    public func performRequest(request: URLRequest, reportId: String, includeLogs: Bool, onSuccess: @escaping () -> Void, onPermanentFailure: @escaping (Error, String) -> Void) -> String {
        performRequestCallCount += 1
        performRequestArgValues.append((request, reportId, includeLogs))
        if let performRequestHandler = performRequestHandler {
            return performRequestHandler(request, reportId, includeLogs, onSuccess, onPermanentFailure)
        }
        return ""
    }
}

Expected source:

  • Add NSObject as super type.
  • Remove public init, as NSObject has a default initializer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant