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

'LineChartView' is unavailable: cannot find Swift declaration for this class #2145

Closed
jrames opened this issue Feb 6, 2017 · 5 comments
Closed

Comments

@jrames
Copy link

jrames commented Feb 6, 2017

I followed the directions outlined in 'Usage' of the Readme to copy the latest Charts master (commit #8532371) into my workspace in Xc8.2.1. I'm receiving the error mentioned in the subject when I attempt to build. Below are details on my setup and what I've tried.

First, I copied the contents of the library to my project folder (using Finder). Then I dragged Charts.xcodeproj under my main workspace. I then added Charts as an embedded binary, and everything looks as I'd expect (it appears in Embedded Binaries and Linked Frameworks). I'm only doing this for Charts.framework as I don't need Realm support.

After doing so, I am able to #import Charts into a Swift file in the project. Autocomplete also picks up the library contents. Here is what I attempted:

let newView = LineChartView(frame: viewRect)

When I build (for the simulator), I get the following error:

'LineChartView' is unavailable: cannot find Swift declaration for this class

I've tried:

  • Adding the path to the framework to my header search paths
  • Cleaning / deleting derived data / restarting Xcode
  • Moving the library to a different location (originally I had it at my root source directory, later moved it straight into my project folder
  • Modifying the target SDK, Supported Architectures, etc to match between my project's target and the Charts target
@danielgindi
Copy link
Collaborator

Did you import Charts?

@liuxuan30
Copy link
Member

will you try ChartsDemo and refer it? Don't see this happens..

@liuxuan30
Copy link
Member

just saw it's a Feb 7 issue, and no response then. closing.

@jrames
Copy link
Author

jrames commented Apr 5, 2017

I did import Charts and spent a lot of time comparing the demo project to my own.

My issue is probably a little unique, but hopefully this helps someone. The problem is that my project has a number of custom named targets (ie not Release or Debug). Because I was compiling Charts as a subproject, Xcode would attempt to compile the target in Charts that corresponded to the target name I was compiling in my main project. When no such match is found, the Release target is compiled in the sub project.

The problem with this is that my header search paths were not set to look at that path. I used an environment variable that pointed to the current build config (I am going off memory so I don't have the variable name handy - will add it in later). So, when I tried to compile the main project, it wouldn't be able to find Charts.framework because it's path was not there.

It threw me off for a bit, because the header path LOOKED correct. In any case, the answer was to add an additional search path that hard coded the /Release path as this would be the default build location in the event of a mismatch.

Hopefully that helps at least one person!

@liuxuan30
Copy link
Member

Thanks @jrames for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants