0

I added the Charts framework (from Danielgindi) to my iOS xcode project using the Swift Package Manager. This installed correctly and the dependency appears to be correct in the config screens. But when I try to add the library to the ViewController.swift file in my empty project with "import Charts" but I get Xcode build error "no such module Charts"

I don't believe this is an issue with my xcode config as I have successfully added other swift packages in exactly the same way and then was able to import their libraries without error. Has anyone else encountered this?

Charts Environment Charts version/Branch/Commit Number:
3.6 (I think whatever latest is) Xcode version: Version 12.2 (12B45b) Swift version: 5.2
 Xcode: 11.1

3
  • I had the same issue about 4 months ago, I resolved the issue by Reset Package Cache and updating all my packages to their latest versions. I also had to remove the pod that was installed for Charts it was causing a conflict in my Build Phase Commented Jan 4, 2021 at 10:40
  • 1
    Usually I solve it by pressing this combination cmd + Shift + k and rebuilding the project. Commented Jan 5, 2021 at 11:21
  • Thanks for both of these suggestions. Unfortunately neither work. I will probably revert to using the pod version - I was just hoping to have the simplicity of the SPM version Commented Jan 8, 2021 at 12:06

1 Answer 1

1

I ran into this same problem and spent the last few hours figuring out a solution so I can start using charts with SPM :-)

First of all, it looks like there are some errors in the current master branch of Charts. There are a few pull requests to fix the issue, here's the one that worked for me. https://github.com/ArthurValiev/Charts/tree/bugfix/spm_build_fix Based on issue #4550

In Xcode I added https://github.com/ArthurValiev/Charts.git to the SPM dialog and typed in branch bugfix/spm_build_fix instead of master and only checked Charts (not DynamicCharts). I then was able to build the project and Import Charts.

This seems to be a temporary solution until the fix is merged into the latest build or master branch.

UPDATE ... This fix has been added the latest master branch. I've successfully imported Charts and built using SPM and master branch. https://github.com/danielgindi/Charts/commit/30cd352013d489ea49fd605dd2c0f3d6c685d0a5

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

4 Comments

Thank you for taking the time to explain your fix. This sounds like a great work around!
I did try this but seem to have the same problem. Xcode can't find the library name after import. I think I'll just revert to pod version.
Xcode will show that it can't find the library name until you build the project, mine did the same thing. Once I did the steps above, I then ran the project to build all everything and the red underline disappeared.
Can this ever be put in plain English? I have no freaking idea how to change my podfile to point to this forked version of Charts.

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.