我在此假設你已經安裝好 Cocoapods 了。
如果你還未安裝。
請參考此鏈接:Cocoapods安裝&解決安裝錯誤&使用
cd 把工程直接拖過來
敲回車
//新建一個podfile文件touch podfile?
敲回車
//使用xcode打開文件open -a xcode podfile?
敲回車
//查找自己需要的第三方庫,Charts search Charts
platform :ios, '8.0'target 'TestCharts' douse_frameworks! pod 'Charts'end
use_frameworks!選項是告訴 CocoaPods 使用 framework 而不是靜態庫。這在 Swift 項目中是必選。 我們添加的那行(pod 'Charts')是讓 CocoaPods 知道我們要用 Charts。
退出的命令是::wq
pod install




找到General->Embedded Binaries,點擊+號添加Charts.framework

橋接文件 項目名-Bridging-Header.h 中,寫上要引用的Swift頭文件。@import Charts;
在ViewController.m中加入如下代碼:
#import "ViewController.h"
#import "HiWorld-Bridging-Header.h"
#import "HiWorld-Swift.h"
@interface ViewController ()
@end
@implementation ViewController
-(void)viewDidLoad {
[super viewDidLoad];
BarChartView *chartView = [[BarChartView alloc] initWithFrame:CGRectMake(10, 10, 300, 300)];
chartView.backgroundColor = [UIColor colorWithRed:0.184 green:1.000 blue:0.738 alpha:1.000];
[self.view addSubview:chartView];
}
@end因為沒有數據。所以,只要這樣的提示。
