正确使用cocoaPods 在OC中集成Charts第三方库

之前的看到的都是错误的!!!!!!!!!!!!

正确的步骤如下:

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

  





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值