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

Most upvoted comments

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:

  • fork repo
  • add s.module_name = 'DGCharts' to podspec in your repo
  • in the Podfile specify your fork
  • replace your import Charts statements with import DGCharts

To resolve this issue:

  • repo owner should decide on module prefix (I used DGCharts as reference to Daniel Gindi as repo owner)
  • change podspec, library name (maybe), and import statements in library (tests) accordingly

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 🙏