總結(jié)導(dǎo)入lottie-ios的艱難過程

今天準(zhǔn)備試一下lottie這個(gè)牛牛的第三方,這個(gè)工具可以把從AE中導(dǎo)出的動(dòng)畫的json文件解析成一個(gè)view供我們使用。lottie的地址是:https://github.com/airbnb/lottie-ios
首先,我是準(zhǔn)備直接在項(xiàng)目中導(dǎo)入這個(gè)框架。本以為很簡單的,可是意外還是發(fā)生了。導(dǎo)入框架lottie-ios之后,編譯通不過,報(bào)了九個(gè)錯(cuò)誤。我明明是按照說明做得,這是怎么回事呢?開始各種google,最終沒有找到原因。具體錯(cuò)誤信息如下:
CADisplayLink.m文件編譯出錯(cuò)9個(gè)。
例如: Unknown type name 'CVDisplayLinkRef'; did you mean 'CADisplayLink'?
在搜索的過程中遇到一位博主,寫了使用lottie的相關(guān)東西,無奈之下,試著在他的文章下面把我的問題提問了一下,沒想到,他竟然回復(fù)了,非常的驚喜。他的回復(fù)如下:
iTerryWang@睡醒的妞妞 我這邊也用你的方式集成了下,確實(shí)會(huì)報(bào)你說的錯(cuò),調(diào)查了下,是因?yàn)門ARGET_OS_IPHONE 這種宏沒有生效。正常的情況,報(bào)錯(cuò)那幾個(gè)文件是macOS平臺(tái)使用的。在編譯iOS平臺(tái)時(shí),不應(yīng)該被編譯。可以嘗試創(chuàng)建一個(gè)pch文件,把#import "TargetConditionals.h"這個(gè)加一下就可以正常編譯了。 不過還是推薦使用pods的方式集成。

我按照他的方法進(jìn)行了實(shí)驗(yàn),真的編譯過了,很開心。在我開心的心情還沒有平靜的時(shí)候,一盆冷水又澆了個(gè)透心涼。
繼續(xù)集成lottie,使用推薦的方法:
LOTAnimationView animation = [LOTAnimationView animationNamed:@"loading"];
[self.view addSubview:animation];
[animation playWithCompletion:^(BOOL animationFinished) {
NSLog(@"動(dòng)畫播放完成");
}];
然后編譯,崩潰啦!崩潰啦!崩潰啦!
崩潰信息如下:
運(yùn)行,結(jié)果崩潰了,崩潰在LOTAnimationView的205行, resourceNotFoundException;這句話。控制臺(tái)給的崩潰信息是:
** Terminating app due to uncaught exception 'ResourceNotFoundException', reason: '(null)'
。好無奈。
放棄使用直接導(dǎo)入的方式了,改用推薦的pod吧。

打開終端,正常的方式建立Podfile文件,寫入
platform:ios,'8.0'
target 'TestLottie' do
pod 'lottie-ios','~>1.5.0'
end

一直pod失敗,提示連接失敗443。以為是終端沒有使用翻墻代理導(dǎo)致的,所以花費(fèi)了兩三個(gè)小時(shí)的時(shí)間在做終端代理的配置。配置了代理之后,還是報(bào)錯(cuò)。為了驗(yàn)證到底是哪里出了問題,先導(dǎo)入AFNetWorking試試,一試發(fā)現(xiàn)成功了,現(xiàn)在可以排除網(wǎng)絡(luò)原因了,應(yīng)該是lottie這個(gè)三方?jīng)]找對(duì)。
錯(cuò)誤信息如下:

bogon:TestLottie aa$ pod install
Analyzing dependencies
Downloading dependencies
Using AFNetworking (3.1.0)
Installing lottie-ios (1.5.0)

[!] Error installing lottie-ios
[!] /usr/bin/git clone https://github.com/airbnb/lottie-ios.git /var/folders/yb/20c1c4sx0q91yqvzlr92n_p80000gp/T/d20170310-59137-kam3xz --template= --single-branch --depth 1 --branch 1.5.0

Cloning into '/var/folders/yb/20c1c4sx0q91yqvzlr92n_p80000gp/T/d20170310-59137-kam3xz'...
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

然后我想到先search一下看看能否找到lottie這個(gè)三方庫。

bogon:TestLottie aa$ pod search lottie-ios
[!] Unable to find a pod with name, author, summary, or description matching `lottie\-ios`

搜索不到這個(gè)三方庫。再搜一下AF試試吧。

bogon:TestLottie aa$ pod search AFNetWorking
[!] Unable to find a pod with name, author, summary, or description matching `AFNetWorking`

AF之前明明已經(jīng)pod成功了,竟然也search不到,繼續(xù)查找原因。然后就找到了,說是本地庫的緩存有問題,在終端執(zhí)行如下命令:

bogon:TestLottie aa$ rm ~/Library/Caches/CocoaPods/search_index.json

再次search,真的成功了!

bogon:TestLottie aa$ pod search AFNetworking
Creating search index for spec repo 'master'.. Done!

再次搜索search lottie,就真的找到了。

9ADF994F-D546-432D-AB09-5893EBD702A1.png

再次執(zhí)行install

bogon:TestLottie aa$ pod install
Analyzing dependencies
Downloading dependencies
Using AFNetworking (3.1.0)
Installing lottie-ios (1.5.0)

[!] Error installing lottie-ios
[!] /usr/bin/git clone https://github.com/airbnb/lottie-ios.git /var/folders/yb/20c1c4sx0q91yqvzlr92n_p80000gp/T/d20170310-59225-l8vqf0 --template= --single-branch --depth 1 --branch 1.5.0

Cloning into '/var/folders/yb/20c1c4sx0q91yqvzlr92n_p80000gp/T/d20170310-59225-l8vqf0'...
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed

結(jié)果,又失敗了。。。。。
仔細(xì)對(duì)比之后發(fā)現(xiàn),這次的錯(cuò)誤和上次的錯(cuò)誤竟然是一樣的!!!看來還是應(yīng)該查找

error: RPC failed; curl 18 transfer closed with outstanding read data remaining

這個(gè)錯(cuò)誤。
尋找之后發(fā)現(xiàn)執(zhí)行下面這個(gè)命令之后就好了:

bogon:TestLottie aa$ Git config --global http.postBuffer 524288000

再次執(zhí)行install,

bogon:TestLottie aa$ pod install
Analyzing dependencies
Downloading dependencies
Using AFNetworking (3.1.0)
Installing lottie-ios 1.5.0 (was 1.0.4)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
bogon:TestLottie aa$ 
Paste_Image.png

終于成功啦!!!!

后來再次查找原來的導(dǎo)入lottie的工程中的崩潰,發(fā)現(xiàn)是我忘記導(dǎo)入loading文件啦,實(shí)在是汗顏。人在著急的狀態(tài)下真的是檢驗(yàn)抗壓和應(yīng)變能力,這種錯(cuò)誤實(shí)在是。。。。。以后不管事情多著急,還是應(yīng)該靜下心來才能事半功倍。繼續(xù)加油吧!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢(shì)1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,436評(píng)論 25 708
  • 屬于我們的時(shí)代結(jié)束了。 以前我一直有舞臺(tái)后遺癥。每次謝幕后都久久不能恢復(fù)正常生活。越大的場(chǎng)合越嚴(yán)重。但是今天。 我...
    南山飲言閱讀 847評(píng)論 0 1
  • 6月12日 日記星球 分享天使 第203天 的確挺了不起的,從打算寫日記到今天,沒想到一晃就過去了2...
    分享天使閱讀 228評(píng)論 0 0
  • 周末傍晚,我正在廚房做晚飯,電話響起,是爸爸。我有點(diǎn)意外,因?yàn)橐话慵依镉惺虑槎际菋寢尨蜻^來,平時(shí)我們打電話也是打給...
    綠蘿吖閱讀 228評(píng)論 0 1
  • 這篇文章主要是一些基礎(chǔ)的知識(shí):包括:GET請(qǐng)求、POST請(qǐng)求、同步請(qǐng)求、異步請(qǐng)求 1、請(qǐng)求的一般步驟 1.確定地址...
    大玲_閱讀 1,946評(píng)論 1 16