Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected behaviour when extending a Swift protocol from another framework (Restofire)

I have two frameworks

First - Restofire. It has a protocol ResponseSerializer with Extension.

public protocol ResponseSerializable {

    /// The type of object returned in response.
    associatedtype Model

    /// The `Alamofire.ResponseSerializer`.
    var responseSerializer: ResponseSerializer<Model, NSError> { get }

}

extension ResponseSerializable {

    /// `CustomJSONResponseSerializer`
    public var responseSerializer: ResponseSerializer<Model, NSError> {
        return AlamofireUtils.JSONResponseSerializer()
    }

}

Second - Restofire-Gloss. It has an extension to a protocol for Models conforming to Decodable that is in the Restofire framework.

public extension ResponseSerializable where Model: Decodable {

    /// `GLOSSResponseSerializer`
    public var responseSerializer: ResponseSerializer<Model, NSError> {
        return GlossUtils.GLOSSResponseSerializer()
    }

}

public extension ResponseSerializable where Model: CollectionType, Model.Generator.Element: Decodable {

    /// `GLOSSResponseSerializer`
    public var responseSerializer: ResponseSerializer<Model, NSError> {
        return GlossUtils.GLOSSResponseSerializer()
    }

}

When i import the source files of Restofire-Gloss directly into the project everything works as expected but when i import the framework, then the control doesn't reach the function in the Restofire-Gloss framework.

like image 650
Rahul Katariya Avatar asked Apr 28 '16 08:04

Rahul Katariya


1 Answers

Maybe you should mark extension as public?

like image 122
Andriy Zymenko Avatar answered Nov 15 '22 22:11

Andriy Zymenko