說(shuō)到Charts真是一把心酸淚,直接git上下載的Charts的demo直接運(yùn)行就報(bào)各種錯(cuò)誤, 整了幾天電腦硬盤都被格式化了也不知道為啥,說(shuō)是要裝什么Carthage整了一天,裝不上,也是就另尋他路了,他路走的也曲折,cocoapods安裝請(qǐng)參考(第六步失敗后,請(qǐng)思考下天朝的網(wǎng)絡(luò)是不是不給力,反正我是重試多次無(wú)用,使用vpn鏈接國(guó)外的網(wǎng)絡(luò)就安裝成功了)不知道是因?yàn)殡娔X系統(tǒng)是10.12的原因,安裝個(gè)cocoapods一直失敗,估計(jì)是網(wǎng)絡(luò)原因吧,不管中間糾結(jié)了多久,反正coocoapos是安裝上去了,
安裝完成后就開(kāi)始引用第三方庫(kù)了參考集成Charts
cocoads安裝:
說(shuō)是macos 10.11以上得用
sudo gem install -n /usr/local/bin cocoapodspod setup集成Charts:
新建一個(gè)項(xiàng)目TestChatDemos
cd 把工程直接拖過(guò)來(lái)touch podfileopen -a xcode podfile在podfile文件中輸入
platform :ios, '8.1'
use_frameworks!
target 'TestCharsDemo' do
pod 'Charts'
pod 'Charts/Realm'
post_install do |installer|
installer.pods_PRoject.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
end
pod search Chartspod install建立與Swift的橋接文件,建立一個(gè)以swift文件,提示是否建立橋接,點(diǎn)擊creat bridging header將pods——testChatDemos。frameworkios添加到 general->embedded binaries在橋接文件中寫上要引用的swift頭文件 @import Charts;用到時(shí)導(dǎo)入 #import “testChartDemos-bridging-header.h”的頭文件,然后就可以使用Charts里的東西了使用ChartsDemos里的東西的時(shí)候,要配置product module name 為(TestCharsDemo)系統(tǒng)會(huì)自動(dòng)生成"TestCharsDemo-Swift.h"的文件,需要手動(dòng)輸入,不會(huì)提示,將Chart-swift.h的文件換成TestCharsDemo生成的"TestCharsDemo-Swift.h"
這樣基本就可以運(yùn)行程序看到ChartsDemo里的案例了
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注