IOS OC project in the integration of Charts draw chart framework

Charts with a frame for a chart, you can draw a bar chart, line chart, chart, pie chart. Because Charts only Swift version, so here the detailed explain in the OC project how to import the Charts framework, the following began to do step by step!

First, download the Charts framework

Download address: https://github.com/danielgindi/Charts.
unzip the contents of the folder inside this is the case, as follows:

IOS OC project in the integration of Charts draw chart framework
after extracting the contents of the folder inside

After downloading, it is important to take a closer look at the environment! Following figure:

IOS OC project in the integration of Charts draw chart framework
required configuration environment

Two, the new project, import Charts.xcodeproj project

1 new projects

New project, named ImportChartsDemo.

2 copy the entire Charts file to the ImportChartsDemo project

Where is Charts? Here, the following figure:

IOS OC project in the integration of Charts draw chart framework
Charts file location

Then copy the Charts file to the ImportChartsDemo project, as shown below;

IOS OC project in the integration of Charts draw chart framework
copy Charts entire file to ImportChartsDemo project
3 import Charts.xcodeproj project

The Charts folder in the Charts.xcodeproj project file into the ImportChartsDemo project, note that the introduction of the Charts.xcodeproj project, rather than the Charts folder, as follows:

IOS OC project in the integration of Charts draw chart framework
import Charts.xcodeproj project
4 add Charts.framework

Find General-> Embedded Binaries, click + number to add Charts.framework, as shown below:

IOS OC project in the integration of Charts draw chart framework
Embedded Binaries position

Add iOS to the framework, as shown below:

IOS OC project in the integration of Charts draw chart framework
add Charts.framework

Three, the establishment of OC and Swift bridge file

In the ImportChartsDemo project to create a new Swift file, the name casually take, this time will prompt whether to establish a bridge file, the direct election of the Create Bridging Header options, as shown below:

IOS OC project in the integration of Charts draw chart framework
to create a bridging file

When the
is completed, it will automatically generate a bridging file, as shown below:

IOS OC project in the integration of Charts draw chart framework
automatically generated bridging file

Four, set compiler options and the introduction of Charts

1 set compiler options

Find Build Settings -> Embedded Contains Swift Code option, set to Yes, as shown in figure:

IOS OC project in the integration of Charts draw chart framework
set compiler options
2 introduction of Charts in a bridging file

Following figure:

IOS OC project in the integration of Charts draw chart framework
introduction Charts
3 in the ViewController.m to introduce the relevant header files

Following figure:

IOS OC project in the integration of Charts draw chart framework
header file

After the completion of the introduction, compile it, if there is a mistake, Clean once again compile, compile error free instructions have been successful

Five, test

In the ViewController.m test, the code is as follows:

BarChartView *chatView = [[BarChartView initWithFrame:CGRectMake (10, 100, 300, 300)] [self.view addSubview:chatView] (alloc]);

Operating results are as follows:

IOS OC project in the integration of Charts draw chart framework
operating results

Because there is no data, so the show is No chart aviailable.
so far, the integration of Charts is completed!
Demo address: https://coding.net/u/wanglei123/p/ImportChartsDemo/git.