In my own code I have this:
extension CLLocationCoordinate2D: Codable {
enum Keys: String, CodingKey {
case latitude = "latitude"
case longitude = "longitude"
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: Keys.self)
let latitudeVal: Double = try container.decode(Double.self, forKey: .latitude)
let longitudeVal: Double = try container.decode(Double.self, forKey: .longitude)
self.init(latitude: latitudeVal, longitude: longitudeVal)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: Keys.self)
try container.encode(latitude, forKey: .latitude)
try container.encode(longitude, forKey: .longitude)
}
}
Now I want to include Mapbox in my app and I added it through Swift Package Manager.
After doing this however I get a redundant conformance to protocol error because Mapbox includes this:
extension CLLocationCoordinate2D: Codable {
public func encode(to encoder: Encoder) throws {
var container = encoder.unkeyedContainer()
try container.encode(longitude)
try container.encode(latitude)
}
public init(from decoder: Decoder) throws {
var container = try decoder.unkeyedContainer()
let longitude = try container.decode(CLLocationDegrees.self)
let latitude = try container.decode(CLLocationDegrees.self)
self.init(latitude: latitude, longitude: longitude)
}
}
Is there a way to restrict this implementation to the imported package, so I can keep using my own extension? Can this be scoped somehow?