上一篇
制作cocoapods私有倉庫(一)依賴庫制作
我們已經做好了依賴庫
這一篇將如何將TestDemo2作為依賴庫來制作cocoapods私有倉庫
依賴庫和cocoapods私有倉庫是兩個概念。所以我們需要再建立一個Spec Repo ,用來管理依賴庫
Spec Repo 只需要一個,可以同時管理多個依賴庫
類似與cocoapods的 公有倉庫master
1.建立管理依賴庫的 Spec Repo
這個倉庫是用來存放我們自己所有的私有庫的 podspec 文件
建立git倉庫參考
制作cocoapods私有倉庫(一)依賴庫制作中git倉庫建立過程
注意觀察一下目錄
將Spec Repo 添加到cocoapods
pod repo add REPO_NAME SOURCE_URL
其中的 REPO_NAME 是我們要添加的私有 repo 的名稱,后面是倉庫的 git 地址。
這里做的其實是創建的工作,也就是在 ~/.cocoapods/repo 目錄下添加了一個以你的私有 repo 為名的文件夾,但是并沒有添加 spec 文件。
pod repo add TestDemo2Spec https://git.oschina.net/ZOKAI/TestDemo2Spec.git
2.添加podspec到Spec Repo
podspec 是cocoapods 安裝使用第三方的依據,Spec Repo管理podspec
pod repo push REPO_NAME PODSPEC
這里必須注意,在push 之前最好檢測一下遠程podspec是否可用
檢測命令
pod spec lint TestDemo2.podspec --allow-warnings --verbose --use-libraries
這個命令和
pod lib lint TestDemo2.podspec --allow-warnings --verbose --use-libraries
很相似,唯一區別就是,前者是檢測遠程podspec,后者是檢測本地podspec
在push到cocoapods是時候,如果檢測的時候使用 --allow-warnings --verbose --use-libraries 這些參數,push的時候也必須同時使用
添加--use-libraries參數,在使用該私有倉庫的時候,還是會報如下錯誤
[!] The 'Pods-NewTestUi' target has transitive dependencies that include static binaries:
(/Users/sqq/Desktop/NewTestUi/Pods/RongCloudIM/RongCloudIM/RongIMKit.framework,
/Users/sqq/Desktop/NewTestUi/Pods/RongCloudIM/RongCloudIM/libopencore-amrnb.a, and
/Users/sqq/Desktop/NewTestUi/Pods/RongCloudIM/RongCloudIM/RongIMLib.framework)
解決方法:
添加如下設置
pre_install do |installer|
def installer.verify_no_static_framework_transitive_dependencies; end
end
當push到cocoapods 出現如下提示,即表示私有倉庫制作成功
pod repo push TestDemoSpec TestDemo2.podspec --allow-warnings --verbose --use-libraries
Validating spec
-> TestDemo2 (1.0.0)
Updating the `TestDemoSpec' repo
Already up-to-date.
Adding the spec to the `TestDemoSpec' repo
- [Add] TestDemo2 (1.0.0)
Pushing the `TestDemoSpec' repo
To https://git.oschina.net/ZOKAI/TestDemo2Spec.git
9485679..d7688af master -> master
此時spec repo會多一個目錄 這個目錄中就是TestDemo2.podspec文件
同時github倉庫上也會多出一行