cd 把工程直接拖過來
敲回車
//新建一個podfile文件 touch podfile
敲回車
//使用xcode打開文件 open -a xcode podfile
敲回車
//查找自己需要的第三方庫 search Charts
platform :ios, '8.0' target 'TestCharts' do use_frameworks! pod 'Charts' end
use_frameworks! 選項是告訴 CocoaPods 使用 framework 而不是靜態庫,這在 Swift 專案中是必選。我們添加的那行(pod 'Charts')是讓 CocoaPods 知道我們要用 Charts。
pod install




General → Embedded Binaries,點擊 + 號添加 Charts.framework。
橋接文件 項目名-Bridging-Header.h 中,寫上要引用的 Swift 頭文件。@import Charts;
#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
文章轉自 青燈素箋的簡書