Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 9 / Swift 4 issue with current master #3152

Closed
zoltansebestyen opened this issue Jan 4, 2018 · 10 comments
Closed

Xcode 9 / Swift 4 issue with current master #3152

zoltansebestyen opened this issue Jan 4, 2018 · 10 comments

Comments

@zoltansebestyen
Copy link

Hi,

I'm trying to use Charts in a project with Xcode 9 / Swift 4, but when building the project - no code yet, just skeleton with Pods - it fails with the errors below. I looked up the project issues, but couldn't find similar one, that's why I created a new one.

My Podfile looks like:

platform :ios, '8.0'
use_frameworks!

target 'OfxCharts' do
  pod "SwiftyXMLParser", :git => 'https://github.com/yahoojapan/SwiftyXMLParser.git'
  pod 'Charts', :git => 'https://github.com/danielgindi/Charts'
end

project 'OfxCharts.xcodeproj'

and I've got the following errors:

Swift Compiler Error Group
Swift Compiler Error Group
OfxCharts/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift:70:76: Cannot use instance member '_viewPortHandler' within property initializer; property initializers run before 'self' is available
OfxCharts/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift:74:77: Cannot use instance member '_viewPortHandler' within property initializer; property initializers run before 'self' is available
OfxCharts/Pods/Charts/Source/Charts/Charts/BarLineChartViewBase.swift:81:72: Cannot use instance member '_viewPortHandler' within property initializer; property initializers run before 'self' is available
OfxCharts/Pods/Charts/Source/Charts/Renderers/BarChartRenderer.swift:611:121: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'
OfxCharts/Pods/ObjectiveC.NSObject:160:15: Did you mean 'zone'?
OfxCharts/Pods/ObjectiveC.NSObject:162:21: Did you mean 'zone'?
OfxCharts/Pods/Charts/Source/Charts/Renderers/BubbleChartRenderer.swift:190:38: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'
OfxCharts/Pods/ObjectiveC.NSObject:160:15: Did you mean 'zone'?
OfxCharts/Pods/ObjectiveC.NSObject:162:21: Did you mean 'zone'?
OfxCharts/Pods/Charts/Source/Charts/Renderers/CandleStickChartRenderer.swift:306:42: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'
OfxCharts/Pods/ObjectiveC.NSObject:160:15: Did you mean 'zone'?
OfxCharts/Pods/ObjectiveC.NSObject:162:21: Did you mean 'zone'?
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:153:33: Incorrect argument label in call (have 'withAttributes:', expected 'attributes:')
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:157:33: Incorrect argument label in call (have 'withAttributes:', expected 'attributes:')
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:162:60: Cannot convert value of type '[NSAttributedStringKey : Any]?' (aka 'Optional<Dictionary<NSString, Any>>') to expected argument type '[String : Any]?'
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:175:33: Incorrect argument label in call (have 'withAttributes:', expected 'attributes:')
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:196:69: Cannot convert value of type '[NSAttributedStringKey : Any]?' (aka 'Optional<Dictionary<NSString, Any>>') to expected argument type '[String : Any]?'
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:204:37: Incorrect argument label in call (have 'withAttributes:', expected 'attributes:')
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:213:69: Cannot convert value of type '[NSAttributedStringKey : Any]?' (aka 'Optional<Dictionary<NSString, Any>>') to expected argument type '[String : Any]?'
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:246:95: Cannot convert value of type '[NSAttributedStringKey : Any]?' (aka 'Optional<Dictionary<NSString, Any>>') to expected argument type '[String : Any]?'
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:261:95: Cannot convert value of type '[NSAttributedStringKey : Any]?' (aka 'Optional<Dictionary<NSString, Any>>') to expected argument type '[String : Any]?'
OfxCharts/Pods/Charts/Source/Charts/Utils/ChartUtils.swift:269:109: Cannot convert value of type '[NSAttributedStringKey : Any]?' (aka 'Optional<Dictionary<NSString, Any>>') to expected argument type '[String : Any]?'
OfxCharts/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift:317:18: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'
OfxCharts/Pods/ObjectiveC.NSObject:160:15: Did you mean 'zone'?
OfxCharts/Pods/ObjectiveC.NSObject:162:21: Did you mean 'zone'?
OfxCharts/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift:349:15: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'font'
OfxCharts/Pods/ObjectiveC.NSObject:160:15: Did you mean 'zone'?
OfxCharts/Pods/ObjectiveC.NSObject:162:21: Did you mean 'zone'?
OfxCharts/Pods/Charts/Source/Charts/Charts/ChartViewBase.swift:350:15: Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'

Do you have some suggestion to resolve the issue?

Thanks,

Zoltan

@jjatie
Copy link
Collaborator

jjatie commented Jan 4, 2018

That's not the latest version of Charts. All of these errors are correct in 3.0.4. I'm guessing you need to update your cocoa pods.

@jjatie jjatie closed this as completed Jan 4, 2018
@zoltansebestyen
Copy link
Author

Are you sure? I cleaned up my local cocapods installation (rm -fr ~/.cocoapods/repos/master; pod setup), explicitly set Charts version to '3.0.4', and still getting the same errors. Actually pod install after the cocoapod update stated that Installing Charts 3.0.4 (was 3.0.4).

@liuxuan30
Copy link
Member

I remember that 3.0.4 does not address some syntax change for swift 4.0.3. Try master?

@jjatie
Copy link
Collaborator

jjatie commented Jan 5, 2018

If that's the case we should really push an update to the pod. Cloning the repo, there are no issues.

@zoltansebestyen
Copy link
Author

Ok, sorted out: I had to set Swift language version to 4.0 for Charts at Pods->Charts->Build Settings->Swift Language Version.
Setting Swift language version to 4.0 at project level wasn't enough. :/

@liuxuan30
Copy link
Member

@jjatie you mean we push current master into pod? master is kind of WIP, but should be fine.

@jjatie
Copy link
Collaborator

jjatie commented Jan 6, 2018

@liuxuan30 Yea. Let's get the last few More Swift into Master PRs done, bump the version to 3.0.5, and push the master to pod.

@lukewcn
Copy link

lukewcn commented Jan 23, 2018

3.0.5 got the same error either

@liuxuan30
Copy link
Member

can't be. I already pushed:

      - 3.0.4 (2017-09-22 03:08:18 UTC)
      - 3.0.5 (2018-01-08 02:33:37 UTC)

@zoltansebestyen
Copy link
Author

For the record: the original root cause was Swift version not set to 4.0, see my earlier comment

@ChartsOrg ChartsOrg locked as resolved and limited conversation to collaborators Jan 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants