1. 項目初始環境
(1)Xcode9.3集成Charts 3.0.2版本;
(2)項目中已存在Charts庫,是以手動集成的方式加入項目的。
2. 刪除原有的Charts文件
(1)右鍵Charts.xcodeproj -> 點擊 Show In Finder
3. 使用pod集成Charts
(1)查看pod支持的Charts版本
1. 執行命令: pod search Charts
(2)編輯podfile文件
1. 打開終端
2. 切換到項目文件目錄下
cd 項目路徑 (直接拖文件)
3. 創建podfile文件
執行命令: touch podfile
4. 進入編輯模式
執行命令: vim podfile -> 點擊“i”鍵
5. 輸入
platform :ios, '8.0'
use_frameworks!
target '項目target名稱' do
pod 'Charts', '3.0.2'
end
6. 退出編輯模式
點擊“esc”鍵 -> 輸入“:wq”退出
(3)導入Charts
1. 執行命令:pod install
- 編譯項目報錯
Error:The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. This setting can be set in the build settings editor.
這是 Cocoapods 管理的第三方框架版本使用的Swift版本與XCode支持的版本不一致造成的。
解決方法: 選擇Pods -> Targets -> Charts -> Swift Compiler - Language -> Swift Language Version -> Swift x.x。即把 Unspecified 改成最新的Swift版本即可。
-
創建橋接文件
圖片(7)
圖片(8)
圖片(9)
橋接文件 “項目名-Bridging-Header.h ”中,引用Charts的Swift頭文件。
注意:如果使用“@import Charts;”會報錯
Use of '@import' when C++ modules are disabled, consider using -fmodules and -fcxx- modules
6.編譯報錯,錯誤和步驟4一樣。因此解決方法相同,只是修改路徑變為
Targets -> Build Setting -> Swift Compiler - Language -> Swift Language Version -> Swift x.x。
- 刪除創建橋接文件時生成的.swift文件
- 將橋接文件導入pch文件或要使用Charts的文件中使用即可。
7月9日更新
在更新iPad項目的時候遇到的問題:
1.錯誤描述
Apple Mach-O Linker Error
clang: error: linker command failed with exit code 1 (use -v to see invocation)
解決方法:
1.查看Build Settings- Other Linker Flags 中是否有一些已經被移除、重復添加的Framework ,確保移除的被移除,添加的只保留一份。
2.在 Build Phases - Link Binary With Libraries 中查看Framework,將白色圖標的庫移除掉。
2.錯誤描述
module file was created by an older version of the compiler; rebuild 'Charts
解決辦法:
項目中原先用的是舊版本的Charts,更新完成后使用Git來回切換過分支,導致項目目錄下的Framework文件夾下存在舊版的Charts庫,Pods中是新版Charts,刪除舊版即可。
3.錯誤描述
dyld`__abort_with_payload
斷點定位在:
dyld`__abort_with_payload:
控制臺的錯誤信息:
有時,控制臺不打印上面的信息
解決辦法:
1.確保XCode版本和Charts庫的版本相對應;如果XCode版本高于Charts庫的版本,建議更新Charts庫。
2.嘗試刪除Charts庫重新導入。