Bizarre, repeated error. In Swift, repeated "Type '' does not conform to protocol ''" after clicking to add stubs. If I click to add the stubs, they appear, but the error doesn't go away; clicking again creates duplicates that say that they're redefinitions. I'm guessing the issues is with the generics, but I'm not sure how.
Yes, I've tried restarting Xcode.
Here's a photo of the error and then the code itself.
Code in a Swift Playground:
// MARK - Locale
protocol LocaleStrategy: Codable {
var locale: String? { get set }
}
struct LocaleStrategyNone: LocaleStrategy {
var locale: String? = nil
}
struct LocaleStrategyCountry: LocaleStrategy {
var locale: String?
}
// MARK - TimeWindow
protocol TimeWindowStrategy: Codable {
var timeWindowInSeconds: Int? { get set }
}
struct TimeWindowStrategyNone: TimeWindowStrategy {
var timeWindowInSeconds: Int? = nil
}
struct TimeWindowStrategyInSeconds: TimeWindowStrategy {
var timeWindowInSeconds: Int?
}
// MARK - Project
protocol ProjectProtocol: Codable {
var localeStrategy: LocaleStrategy { get set }
var timeWindowStrategy: TimeWindowStrategy { get set }
}
struct Project<LocaleStrategy: Codable, TimeWindowStrategy: Codable>: ProjectProtocol { // <-- ERROR: Type 'Project<LocaleStrategy, TimeWindowStrategy>' does not conform to protocol 'ProjectProtocol'
var localeStrategy: LocaleStrategy
var timeWindowStrategy: TimeWindowStrategy
}
let localeStrategyCountry = LocaleStrategyCountry(locale: "USA")
let timeStrategyNone = TimeWindowStrategyNone()
let project = Project(localeStrategy: localeStrategyCountry, timeWindowStrategy: timeStrategyNone)
let localeStrategyNone = LocaleStrategyNone()
let timeWindowStrategyInSeconds = TimeWindowStrategyInSeconds(timeWindowInSeconds: 3)
let project2 = Project(localeStrategy: localeStrategyNone, timeWindowStrategy: timeWindowStrategyInSeconds)
let projects: [ProjectProtocol] = [project, project2]
