shenyu
August 31, 2023, 1:15am
1
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:
(…/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?
SDK Version: 49.0.8
Platforms(Android/iOS/web/all): iOS
Thanks so much!!
wodin
August 31, 2023, 4:46am
2
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?
shenyu
September 4, 2023, 3:16pm
3
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
}
}