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

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

3.0.3 will not work in this case. He is on XCode 8.3, not 9
@MartinMuldoon Oops! It's a typo... I wrote 3.0.2 a line above the code block. Fixed now.
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.
@Sweeper I am accepting the answer as it solved the issue. Can you have a look at a new issue I am facing now -stackoverflow.com/questions/49767947/charts-pod-not-downgrading
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

3 Comments

I had set the platfom to ios 9.0 and I was using pod 'Charts' before I found this github.com/danielgindi/Charts/issues/2332
I am bit confused. Do I need Xcode 9.3 / Swift 4.1 as stated here cocoapods.org/pods/Charts
I'll update my answer. It is your version of Xcode/Swift that is the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.