主要步驟
- 剝離宿主工程代碼到組件中;
- 解決依賴:把宿主工程的Podfile文件中的依賴關系,轉移到組件的podspec文件中;
- 測試Example代碼。
詳細步驟
####### 1. 創(chuàng)建模板pod lib create MainModule
,骨架組件化,拖入骨架文件;(創(chuàng)建庫模板)
骨架模板庫.png
####### 2.修改podspec和Podfile: 解決組件間依賴問題,比如業(yè)務組件依賴基礎組件的分類子庫;(修改podspec文件)
2.1 搜索一下基礎組件 pod search LFProject_my0707
;
搜索私庫基礎組件.png
2.2 podspec文件添加庫依賴,Podfile中沒有加公私庫source
// 依賴大庫LFProject_my0707中的子庫Category
s.dependency 'LFProject_my0707/Category'
// Podfile:
source 'https://git.oschina.net/lovell123/lfspec_my0707.git'
source 'https://github.com/CocoaPods/Specs.git'
如果Podfile中沒有加公私庫source會報錯:
[!] Unable to find a specification for `LFProject_my0707/Category` depended upon by `LFFMMain`.
####### 3.測試:Example測試工程AppDelegate文件加入創(chuàng)建TabBarController的代碼,編譯報錯根據(jù)路徑找不到某個xib。
報錯解決辦法在下一篇資源的加載。
Snip20170711_104.png
####### 4.上傳代碼、打標簽、推送podspec文件
git status
git add .
git commit -m '1'
git remote
git remote add origin http......
git push origin master
git tag
git tag '0.1.0'
git push --tags
pod lib lint
pod spec lint
pod repo
pod repo push <repo name> <spec file name>