Search code examples
iosswiftxcodechartsxcode14

Charts not compile on Xcode 14


I am facing following errors in library -

  • Type 'ChartDataSet' does not conform to protocol 'RangeReplaceableCollection'

  • Unavailable instance method 'replaceSubrange(_:with:)' was used to satisfy a requirement of protocol 'RangeReplaceableCollection'.


Solution

  • Append it to extension ChartDataSet: RangeReplaceableCollection

    public func replaceSubrange<C>(_ subrange: Swift.Range<Int>, with newElements: C) where C : Collection, ChartDataEntry == C.Element {
        entries.replaceSubrange(subrange, with: newElements)
        notifyDataSetChanged()
    }