Charts: Conflict with Apple's Swift Charts
Is anyone else having issues while doing
import Charts
in SwiftUI ? It am trying to use Apple’s Swift Charts (iOS 16 only) but it can’t compile, I presume because the import statement is interpreted as targeting this library and not Apple’s Swift Charts as I want to.
Any fix, workaround or way to specify better what to import is welcomed, haven’t found any other solution than nuking this library from my project, however I would need it for users with iOS 15 or less.
What did you do?
Tried to use Apple’s Swift Charts in some SwiftUI view in my app that uses this Github repo (https://github.com/danielgindi/Charts) in other places of the app, installed via cocoa pods.
I naturally do
import Charts
to import Apple’s library, however it seems the compiler does not understands it that way as I can not use Swift Charts’s charts in my SwiftUI struct view.
What did you expect to happen?
I expected this Chats library to not interfere.
What happened instead?
I seem to be unable to use Swift Charts because of this library
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 20 (4 by maintainers)
Commits related to this issue
- Update Charts.podspec https://github.com/danielgindi/Charts/issues/4897 — committed to yapwr/Charts by yapwr 2 years ago
- Distinguish module from Swift Charts with podspec As per temporary solution proposed [here](https://github.com/danielgindi/Charts/issues/4897#issuecomment-1240652977) we rename a module on pod spec t... — committed to AURA-Devices/Charts by Nikolas-LFDesigns 2 years ago
- Distinguish module from Swift Charts with podspec (#1) As per temporary solution proposed [here](https://github.com/danielgindi/Charts/issues/4897#issuecomment-1240652977) we rename a module on pod s... — committed to AURA-Devices/Charts by Nikolas-LFDesigns 2 years ago
This is because module name collision - this library uses the same module name that is used by new Swift Charts framework (available since iOS 16.0, mac OS 13.0).
Workaround:
s.module_name = 'DGCharts'to podspec in your repoimport Chartsstatements withimport DGChartsTo resolve this issue:
DGChartsas reference to Daniel Gindi as repo owner)I haven’t pushed it yet but I’ve basically finished the renaming. I just need to validate that all build tools keep working.
sorry. I already saw #5009 working on this.
This would be very useful 🙏