skip to Main Content

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‘.

6

Answers


  1. Chosen as BEST ANSWER

    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()
    }
    

  2. It was fixed on Master brunch

    Add master brunch to your project, instead of "Up to next major version" in SPM.
    And use in CacaoPods: `

    pod ‘Charts’, :git => ‘https://github.com/danielgindi/Charts.git’,
    :branch => ‘master’

    Login or Signup to reply.
  3. I have newly installed XCode 14.1 and found multiple error on the Charts cocoapod library. Found multiple solutions online but none worked fully and made sense to me. Finally using swift package manager for Charts solved the problem like a charm.

    Solution: Remove Charts pod from Podfile and add SPM (Swift Package Manager) for the same using url:

    https://github.com/danielgindi/Charts.git
    

    Make sure you change version to:

    upToNextMajor(from: "4.1.0")
    

    enter image description here

    Login or Signup to reply.
  4. Same thing happened to me.
    I am using the swift package manager to import charts and the error went away after updating the swift package manager. However, the charts version remains 4.0. Packages other than charts may be the culprit.

    Login or Signup to reply.
  5. I am using Xcode 14.2. I removed the Charts from the podFile and then added it via SPM. However, beware to only include Charts (4.1.0) and not Dynamic Charts. The latter will result in a "Module not found" error for Algorithms

    Login or Signup to reply.
  6. Increase the platform version to platform :ios, ‘12.0’ or above in your Podfile.
    And then add pod ‘Charts’ into the pod file. Then hit pod install in the terminal, the version installed will be 14.0.1 which is currently the latest, this will resolve the issue.
    If you face issue with initializing charts after the above step then add this piece of code to resolve the error,

    let pieChartDataSet = PieChartDataSet(entries: dataEntries, label: "") 
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search