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
How can I use this library from another project? #24
Comments
Yop, I have the same question. Is it possible without Pod install? |
In the end I went with the Pod install, plus a bridging header. It seems to work okay for me so far! |
Can you share it for me please? (of course, some example) Thank you so much man! :) |
Ah man I'm sorry, my reply was slightly incorrect - so I ended up using a Podfile that references the original PNChart repo, not the swift one. As far as I can tell, there's no Pod available for the swift library, which might actually be because CocoaPods don't yet allow you to add Swift projects to your workspace. I'm not sure. Anyway, what I did was add the non swift library - this is what I had to do: There's not much to it, really - two major things are getting the podfile right and installing pods, and then setting up the Bridging header to the Objective-C libaries. Your podfile should look something like this (for IOS8, of course) Once you've got the PNChart project added to your workspace from installing the pods, you'll need a bridging header in your project. This lets Swift interact with the Objective-C classes in the PNChart project. You can read more about bridging headers here: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html (look for subsection Importing Objective-C into Swift) Enable your bridging header in your project settings: To get the charts to work, your bridging header should have these lines in it: Basically, from there, your project should have access to anything you want in PNCharts. On the ViewControllers where you use charts, you'll need to import a reference to the PNCharts library: From there, everything should be according to the documentation in the PNCharts repo's readme (And their sample projects). |
Wau, THANK YOU for help! I will try it to do this evening. :) Thank you Mike!! |
Still not working for me. :/ I mean I wrote something bad. If I paste the Obj-C code from example to viewDidLoad function, will work? For me not working. (I know, is it Obj-C, but the bridging know work with it...?) |
Hi @vlafiser - so you're not going to be able to write Obj-C code. You'll need to translate it to Swift, essentially, which can be a bit of a pain, but is a great learning experience. For example, my ViewDidLoad() code looks like this for the ViewController in question: |
@mbifulco are these directions for JBCharts (https://github.com/Jawbone/JBChartView) or PNCharts? |
Wow, yeah, I'm all over the map. Sorry... disregard me completely. I did switch to JB at some point. Sorry @m-t-space and @vlafiser |
Went back and tried to put together an example using PNChart earlier, and even with a blank Swift project, I'm having trouble getting the cocoapod to connect to my project through the bridging header and compile happily. I'll play with it a bit more this weekend and let you know if I can get it going (and share my code). |
Hey @mbifulco , Any good? |
A bit of a noob question, but I'm looking to use the PNChart-Swift library in a swift project I'm working on. Is there a trick to using is as a framework, or referencing it from an external project?
The text was updated successfully, but these errors were encountered: