之前的看到的都是错误的!!!!!!!!!!!!
正确的步骤如下:
1.安装cocoaPods
2.新建一个OC工程
3.pod init 到 vi Podfile
# Uncomment the next line to define a global platform for your project
platform :ios, '11.2'
target 'Chartsssss' do
# Uncomment the next line if you're using Swift or would like to use dynamic frameworks
use_frameworks!
pod 'Charts'
target 'ChartsssssTests' do
inherit! :search_paths
# Pods for testing
end
target 'ChartsssssUITests' do
inherit! :search_paths
# Pods for testing
end
end
4.将工程中Pods的编译语言设置为SWIFT最新版本
build Settings ->Swift Language Version
5.将Chart.framework添加到新建的项目中
点击新建的项目->Build Phases->Link Binary With Libraries-> "+" -> 找到Charts.frame添加
6.添加OC与Switf桥接
在工程中新建一个Swift文件,名字随便取,如"Chart-Bridging-Header.h",这时候会提示是否建立桥接文件,直接选Create Bridging Header选项,名字无 所谓,会自动建立一个桥接文件。
在桥接文件里写入
@import Charts;
6.测试
#import "ViewController.h"
#import "Chart-Bridging-Header.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
BarChartView *chatView=[[BarChartView alloc]initWithFrame:CGRectMake(0, 40, 300, 300)];
chatView.backgroundColor=[UIColor blueColor];
[self.view addSubview:chatView];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end