Search code examples
iosswiftreactive-cocoareactive-swift

Use of undeclared type 'SignalProducerType


I am new to ReactiveCocoa and ReactiveSwift, I am having task of update code from Swift2 to Swift4 after updating code i stuck in one point where I encountered error for "Use of undeclared type 'SignalProducerType'" not found do we have any alternative for this ? Please help me in resolving this issue i am using ReactiveCocoa 7.1.0

extension SignalProducerType where Value == HTTPOperationResult,Error == APIError {

    func serializeToJSON() -> SignalProducer {
        return attemptMap { result in
            guard let data = result.data else {
                return .failure(APIError.parseError("invalid json"))
            }
            guard let JSON = try? JSONSerialization.jsonObject(with: data, options: []) else {
                return .failure(APIError.parseError("invalid json"))
            }
            return .success((result,JSON))
        }
    }
}

Solution

  • SignalProducerType no longer exists. It was renamed to SignalProducerProtocol, but it isn't used to add operators anymore. This ought to just be an extension on SignalProducer itself:

    All Signal and SignalProducer operators now belongs to the respective concrete types. (#304)

    Custom operators should extend the concrete types directly. SignalProtocol and SignalProducerProtocol should be used only for constraining associated types.