1

I am new in swift and I am trying to add Charts pod using -

pod 'Charts', :git=> 'https://github.com/danielgindi/Charts.git'

And I am getting following issues after adding Charts pod

.../Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift:75:76: Cannot use instance member '_viewPortHandler' within property initializer; property initializers run before 'self' is available
.../Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift:79:77: Cannot use instance member '_viewPortHandler' within property initializer; property initializers run before 'self' is available
.../Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift:86:72: Cannot use instance member '_viewPortHandler' within property initializer; property initializers run before 'self' is available
.../Pods/Charts/Source/Charts/Components/AxisBase.swift:137:24: 'count' is unavailable: there is no universally good answer, see the documentation comment for discussion

I am using swift 3 and Xcode 8.3

Shunan
  • 3,165
  • 6
  • 28
  • 48

2 Answers2

3

The current version of Charts seem to support Swift 4.1. You need a version that supports Swift 3.1, which is what Xcode 8 has.

According to the version history, Charts 3.0.2 supports Swift 3.1, so you should install that version:

pod 'Charts', '3.0.2'

Do a pod install after that.

Obviously, you can also choose to update to Xcode 9 and Swift 4.

Sweeper
  • 213,210
  • 22
  • 193
  • 313
  • 3.0.3 will not work in this case. He is on XCode 8.3, not 9 – Martin Muldoon Apr 10 '18 at 09:43
  • @MartinMuldoon Oops! It's a typo... I wrote 3.0.2 a line above the code block. Fixed now. – Sweeper Apr 10 '18 at 09:44
  • Thanks, @Sweeper for your answer. I understood the issue but pod 'Charts', '~> 3.0.2' not working. It's still using still using 3.0.5 when I try to update or install pod. – Shunan Apr 11 '18 at 06:00
  • @Sweeper I am accepting the answer as it solved the issue. Can you have a look at a new issue I am facing now -https://stackoverflow.com/questions/49767947/charts-pod-not-downgrading – Shunan Apr 11 '18 at 06:28
1

Given you are using Swift 3, Xcode 8.3, you'll have to install an older release of Charts. The various releases can be found on the menu bar under releases:

enter image description here

I believe this release should install properly: https://github.com/danielgindi/Charts/releases/tag/v3.0.2

Martin Muldoon
  • 3,388
  • 4
  • 24
  • 55