IDE: Fire Version: Version 10.0.0.2398 (develop) built on talax, 20190425-190525. Commit e0b3c5f. Target (If relevant): iOS Description:
I have been working on a little form library inspired by Eureka for Silver and I am experiencing some issue with protocols. For some reason I can’t seem to fulfill the protocol for a class. It’s giving the following compiler error:
E: Method "func BaseRowType!.title -> RemObjects.Elements.RTL.String?" not implemented as required for interface "BaseRowType" [/Users/x/Desktop/Bug/App2/Form/BaseRow.swift (3)]
N: Possible match: func title -> String? [/Users/x/Desktop/Bug/App2/Form/BaseRow.swift (6)]
N: Type "BaseRowType" was declared here [/Users/x/Desktop/Bug/App2/Form/RowType.swift (5)]
E: Method "func Taggable!.tag -> RemObjects.Elements.RTL.String?" not implemented as required for interface "BaseRowType" [/Users/x/Desktop/Bug/App2/Form/BaseRow.swift (3)]
N: Possible match: func tag -> String? [/Users/x/Desktop/Bug/App2/Form/BaseRow.swift (14)]
/Users/x/Desktop/Bug/App2/Form/RowType.swift(5,17): duplicate-warning N4: Type "BaseRowType" was declared here
Expected Behavior:
My exception would be that this code would compile
Actual Behavior:
The above compiler error is happening
The problem are the different import clauses. where the interfaces are defined, String is RemObjects.Elements.RTL.String; where you implement it, String is Foundation.(NS)String, I’m guessing because UIKit is imported after RemObjects.Elements.RTL and that apparently pulls in Foundation (not sure if that is expected, it surprises me, I’ll ask @ck).
when you type “String”, which type you refer to is determined by the namespaces you have imported, either at the top of the file or via the Default Uses Clause project setting.
The latter contains RemObjects.Elements.RTL for your project, so in RowType.swift, which has no import clauses, that’s in scope, and gets used for your property:
var title: String? { get set } // implies RemObjects.Elements.RTL.String
in BaseRow.swift you have an import UIKit clause. this brings the UIKitandFoundation (the latter surprises me and I need to check about with @ck) namespaces into scope, on top of RemObjects.Elements.RTL. So now String refers to Foundation.String:
import UIKit
open class BaseRow: BaseRowType {
/// The title will be displayed in the textLabel of the row.
public var title: String? // implies Foundation.String
To fix this, make sure your uses/import clause is consistent WRT Foundation vs RemObjects.Elements.RTL — I would recommend adding UIKit to the Default Uses Clause setting, before RemObjects.Elements.RTL, eg: