It is normal for Moya to add plugins in version 14.0, but plugins below 14.0 will fail. Import import Result to solve the problem

//
// MoyaInterceptor.swift
// iOS
//
// Created by iOS on 2021/4/7.
// Copyright © 2021 iOS. All rights reserved
//

import UIKit
import Moya
import Result

struct DebugLogPlugin: PluginType {
    
    /// There is still a chance to modify the request before sending it
    func prepare(_ request: URLRequest.target: TargetType) -> URLRequest{
        return request
    }
    
    /// called before sending
    func willSend(_ request: RequestType.target: TargetType){}
    
    /// After the Response is received and before the callback is triggered
    func didReceive(_ result: Result<Moya.Response.MoyaError>, target: TargetType){
        switch result {
        case .success(let response):
            debugPrint(response)
        case .failure(let error):
            debugPrint(error.errorDescription ?? "Unknown error")}}/// Result can also be modified before Callback is called
    func process(_ result: Result<Response.MoyaError>, target: TargetType) -> Result<Response.MoyaError> {
        return result
    }
  
}



Copy the code