Skip to content

Uncompilable mock generated for NSObjectProtocol / @objc protocols  #248

Open
@DJBen

Description

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions