Reputation: 3627
I am trying to use this charting library which is a port of the same library I use for Android:
https://github.com/danielgindi/ios-charts
Since i use Swift targeting ios7+ I decided to follow this guide:
If you want to compile for iOS 7:
Drag the code itself (.swift files) to your project. As sadly, Swift currently does not support compiling Frameworks for iOS 7. Make sure that the files are added to the Target membership.
So I have done basicly placed a copy of the entire ios-charts folder in my project folder next to my own .swift files.
Then removed all units but .swift but keeping the file/directory structure. Interestingly, I can not change/add targets for any of the files in the folder since the option does not show itself when clicking the .swift files in xcode.
I then drop an UIView and change class to e.g. BarChartView.
I create an outlet so I have this in my class definition:
@IBOutlet weak var myStickChart: BarChartView!
However, I when building I am getting error
use of undeclared type "BarChartView
This is probably a simple problem, but this is the first 3rd party library I have to use.
I have experiemented with pods before, but decided against it - I would rather, for now as long as I am targeting ios7, be able to drag in he untts I want to use like descrived in the instructions for ios-charts with swift/ios7
Upvotes: 1
Views: 1200
Reputation: 13354
Following steps worked for me:
pod 'Charts'
charts
it will not read that file or class and you will see the error like use of undeclared type xxxxx
. So for this GoTo ⇾ Project Target ⇾ General ⇾ Linked Frameworks and Libraries ⇾ Click on + button and add Charts.framework
.import Charts
and now
you will be able to use this framework without any error.Upvotes: 0
Reputation: 5554
implementing this library for iOS 7 has it's own special challenges. The instructions advise you to Drag the code itself (.swift files) to your project - and when I did that at first I dragged over the top-level folder (like you would) but I couldn't get it to work.
Then I copied over each group of files individually - I put them all in the same folder Charts
, but I guess you could recreate the folder structure.
Now I have a simple project working with Charts
, iOS 7
, and with no need for import
Just to be clear - here's how the file structure looks in my project - not very elegant, but it works.
Upvotes: 2
Reputation: 5554
@Tom - I use the same classes in one of my projects, and I installed it in exactly the same way as you do. I can generate the same errors that you're seeing - but only if I remove import Charts
from my class definition.
Here's what the start of my class definition looks like
import UIKit
import Charts
class SharePriceGraphViewController: UIViewController, ChartViewDelegate
{
var myStickChart: BarChartView! // I don't really have this - added for this test :-)
as it stands, this compiles nicely. if I remove the import - I get the same error as you do.
Upvotes: 2