Third-party native library on iOS

Hi, I am following Use third-party native libraries in Expo - Expo Documentation to try it out. The android worked fine. However when I tried to run npx expo run:ios, I got the following error:

:x: (…/ios/ExpoRadialChartView.swift:13:19)

11 |
12 | class ExpoRadialChartView: ExpoView {

13 | let chartView = PieChartView()
| ^ cannot find ‘PieChartView’ in scope
14 |
15 | required init(appContext: AppContext? = nil) {
16 | super.init(appContext: appContext)

I double checked the code and they are the example project has. I am not sure where I missed. Anyone has seen this before?

  1. SDK Version: 49.0.8
  2. Platforms(Android/iOS/web/all): iOS

Thanks so much!!

Hi @shenyu

Can you provide more context? e.g. what third party library is this?

Also, I see the file is called ExpoRadialChartView.swift, but the line it’s complaining about is talking about a pie chart rather than a radial chart. Is that correct?

Thanks @wodin. The file name is from the module I created following the sample example, using npx create-expo-module expo-radial-chart.
The 3rd party library is Charts (GitHub - danielgindi/Charts: Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.). The code that triggered the error is this, line 12.

import ExpoModulesCore
import Charts

struct Series: Record {
  @Field
  var color: UIColor = UIColor.black

  @Field
  var percentage: Double = 0
}

class ExpoRadialChartView: ExpoView {
  let chartView = PieChartView()

  required init(appContext: AppContext? = nil) {
    super.init(appContext: appContext)
    clipsToBounds = true
    addSubview(chartView)
  }

  override func layoutSubviews() {
    chartView.frame = bounds
  }

  func setChartData(data: [Series]) {
    let set1 = PieChartDataSet(entries: data.map({ (series: Series) -> PieChartDataEntry in
      return PieChartDataEntry(value: series.percentage)
    }))
    set1.colors = data.map({ (series: Series) -> UIColor in
      return series.color
    })
    let chartData: PieChartData = [set1]
    chartView.data = chartData
  }
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.