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

Confused as to how to install using CocoaPods #862

Closed
tachang opened this issue Mar 20, 2016 · 3 comments
Closed

Confused as to how to install using CocoaPods #862

tachang opened this issue Mar 20, 2016 · 3 comments

Comments

@tachang
Copy link

tachang commented Mar 20, 2016

I have read numerous issues on how to install but am failing pretty badly.

I have a pure objective-c project and am using CocoaPods. I believe this is a very common scenario.

So first thing I do is look at "CocoaPods Install" of the README and add it into my Podfile:

platform :ios, '9.0'
pod 'Charts'
use_frameworks!

Do a pod install and everything works.

I even am able to create a view and use Module 'Chart' and BarChartView as the class. And it compiles and I see "No chart data available" in orange.

However now I am trying to add a reference to that chart but I can't figure out what to import. I've tried to import lots of different things but none of it is resolving. What do I do in this case?

@pmairoldi
Copy link
Collaborator

The name you use for import is the module name so for this library it's import Charts

@tachang
Copy link
Author

tachang commented Mar 20, 2016

Okay I believe what is confusing is that this is the correct way to do it but you need to add the line

@import Charts;

to your .h file.

What was confusing to me is that when I saw "@import" it looked kinda like Swift syntax/code so I ignored it thinking I had to do something like #import <Charts/Charts.h> or something like that. When in fact "@import Charts" is a perfectly valid statement and will compile (is it converting it to objective-c in the background or is that actually valid? Like is the preprocessor converting it).

Thank you.

@tachang tachang closed this as completed Mar 20, 2016
@danielgindi
Copy link
Collaborator

It's perfectly valid ObjC, since iOS 8 where Apple have introduced Modules.
Instead of #includeing specific headers and looking at the docs to figure out which- you can @import a module.
This also layed the ground for Swift's import and is the reason that you don't worry about .h files in Swift.

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