部分參考了使用 CocoaPods 打包html
//安裝
sudo gem install cocoapods-packager
//更新
sudo gem update --system
sudo gem install cocoapods
sudo gem install cocospods-trunk
複製代碼
//註冊(要去郵箱裏點擊確認,流程纔算完。)
pod trunk register xxx@163.com 'Yang' --description='Yang's xhzy mac' //查看這個設備上的帳號、相關設備信息、相關倉庫信息。 pod trunk me //換臺電腦,須要登陸(註冊一個session)cocoapod倉庫. (同樣要去郵箱確認身份) //一個帳號能夠有多臺設備。 pod trunk register xxx@163.com //給pod倉庫添加owner, 至關於github上,添加開發者。 pod trunk add-owner SHWChatRobotNOUI xxx@gmail.com 複製代碼
pod lib create [pod name]
複製代碼
比較好的作法是,ios
項目 | git項目名 | 工程名 | podspec name |
---|---|---|---|
源碼 | shw-voice-sdk-sourcecode | SHWVoice | SHWVoice |
sdk | shw-voice-sdk | SHWVoiceSDK | SHWVoiceSDK,spec文件中指定的framework是SHWVoice.framework |
SDK
字樣SDK
,實際framework不帶SDK
上一步操做,.gitignore已經自動生成。git
不管源碼打包,framework提交,都要先校驗。github
//有靜態庫依賴時,須要加上選項 --use-libraries
pod lib lint SHWAccount.podspec --allow-warnings --use-libraries
//對於有私有庫依賴的庫,校驗時須要加上--source
pod lib lint SHWAccount.podspec --allow-warnings --use-libraries --sources="https://code.aliyun.com/xhzy-ios/frameworkplatform.git,https://github.com/CocoaPods/Specs.git"
複製代碼
打包時注意s.version的版本號。web
//--no-mangle,表示不把第三方源碼、framework打進去
//--exclude-deps,解決pod-numm衝突,不包含依賴的符號表
//--force,強制覆蓋以前已經生成過的二進制庫
pod package SHWAccount.podspec --force --no-mangle --exclude-deps
//對於有私有庫依賴的庫,打包時須要加上--spec-sources
$ pod package SHWAccount.podspec --force --no-mangle --exclude-deps --spec-sources="https://code.aliyun.com/xhzy-ios/frameworkplatform.git,https://github.com/CocoaPods/Specs.git"
複製代碼
pod repo add REPO_NAME SOURCE_URL
複製代碼
pod repo push platform XYiOSComponent.podspec
//--use-libraries 若是有.a就須要添加這個選項
複製代碼
pod trunk push xx.podspec --allow-warnings --use-libraries //--use-libraries 若是有.a就須要添加這個選項
複製代碼
pod_trunk_deletejson
pod trunk deprecate xxx
pod trunk delete xxx 0.5.8
複製代碼
Pod二進制化,能夠參考,但一些參數的描述和項目實際使用中不太同樣。swift
同版本號打屢次無效
)~/Library/Caches/CocoaPods/Pods/Specs/Externalxcode
#6 Podfile緩存
source 'https://github.com/CocoaPods/Specs.git'
inhibit_all_warnings!
platform :ios, "9.0"
#use_frameworks!
#能夠對多個target設置不一樣的引用
target "WorkApp" do
pod 'Masonry'
pod 'AFNetworking'
end
複製代碼
use_frameworks!
把lib-Pod達成framework,而不是.a,用於swift中,oc中不要加這句,可能報錯。bash
source 'https://github.com/CocoaPods/Specs.git'
inhibit_all_warnings!
platform :ios, "8.0"
target 'SHWRecommendUI_Example' do
#這裏能夠改
pod 'SHWRecommendUI', :path => '../'
pod 'YYText'
target 'SHWRecommendUI_Tests' do
inherit! :search_paths
pod 'Kiwi'
end
end
複製代碼
//Podfile
install! 'cocoapods', generate_multiple_pod_projects: true
複製代碼
以前Cocoapods把每一個依賴做爲 target 放到 Pods 項目裏,因爲 xcodeproj 編碼緣由,pod多的時候,解析的效率會急劇降低。 generate_multiple_pod_projects選項,讓每一個依賴都做爲一個單獨的項目引入,大大增長了解析速度.
系統升級後的一些問題提示 pod search 出錯 pod search 找不到 s.source源引發的問題
Pod::Spec.new do |s|
s.name = 'SHWAnalyticsSDK'
s.version = '1.2.2'
s.summary = 'Analytics framework.'
s.description = "巴吉度 iOS SDK 源碼"
s.homepage = 'https://code.aliyun.com/xhzy-ios/SHWAnalytics'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "yangyang" => "xxx@xxx.com" }
#s.source = { :git => 'git@code.aliyun.com:xhzy-ios/ios-account-sdk.git', :tag => s.version.to_s }
# develop source
s.source = { :git => 'git@code.aliyun.com:xhzy-ios/ios-analytics-sdk.git'}
s.ios.deployment_target = '9.0'
s.source_files = 'SHWAnalyticsSDK/Classes/**/*'
s.public_header_files = 'SHWAnalyticsSDK/Classes/Public/*.h'
s.frameworks = 'CoreLocation','CoreTelephony','Foundation','JavaScriptCore','UIKit','WebKit', 'SystemConfiguration','CoreFoundation','Security'
s.dependency 'UTDID', '~> 1.0.0'
end
複製代碼
Pod::Spec.new do |s|
s.name = 'SHWAIConversation'
s.version = '1.52.0'
s.summary = 'xxx'
s.homepage = 'https://code.aliyun.com/xxx'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'yangyang' => 'youxiang' }
s.ios.deployment_target = '9.0'
# s.source = { :git => 'git@code.aliyun.com:xxx.git', :tag => s.version.to_s}
s.source = { :git => '/Users/yayang/Desktop/SHWAIConversation'}
s.source_files = 'SHWAIConversation/Classes/**/*'
s.public_header_files = 'SHWAIConversation/Classes/public/*.h'
s.resources = 'SHWAIConversation/Resource/*'
s.frameworks = 'CoreLocation', 'SystemConfiguration', 'CoreFoundation', 'JavaScriptcore', 'CoreTelephony', 'Security', 'AudioToolbox', 'CoreMotion', 'OpenGLES', 'CoreGraphics', 'AVFoundation'
s.libraries = 'icucore'
#第三方.a
s.ios.vendored_library = 'SHWNLSClient/Classes/3rd/Opus/lib/libopus.a'
# subspec
s.subspec 'NlsClientSDK' do |nls|
nls.name = 'NlsClientSDK'
nls.frameworks = 'CoreLocation', 'SystemConfiguration', 'CoreFoundation', 'JavaScriptcore', 'CoreTelephony', 'Security', 'AudioToolbox', 'CoreMotion', 'OpenGLES', 'CoreGraphics', 'AVFoundation'
nls.libraries = 'icucore'
#第三方framework
nls.ios.vendored_frameworks = 'SHWAIConversation/Frameworks/NlsClientSDK.framework'
end
# dependencys
s.dependency 'Masonry', '~> 1.1.0'
end
複製代碼
目的:爲了提早發現問題,能夠在不提交的狀況下進行測試。 實現方式:有兩種
s.source = { :git => '/Users/yayang/Desktop/SHWAIConversation'}
複製代碼
source 'https://github.com/CocoaPods/Specs.git'
inhibit_all_warnings!
platform :ios, "8.0"
target 'SHWRecommendUI_Example' do
#這裏有個大坑,注意要依賴於實際源碼,而不是打包出的源碼,如/Users/yangyang/Documents/code/workspace/test6/YangTest1Resource/YangTest1Resource-0.2.6
pod 'SHWRecommendUI', :path => '/Users/yangyang/Documents/code/workspace/test6/YangTest1Resource'
target 'SHWRecommendUI_Tests' do
inherit! :search_paths
pod 'Kiwi'
end
end
複製代碼
s.resource = 'NewsFeedsUISDK/NewsFeedsUISDK.framework/Versions/A/Resources/NFUIBundle.bundle'
The document could not be saved. The file doesn’t exist.
關掉Xcode,用Xcode單獨打開這個文件,修改保存關閉。
再用Xcode打開項目。This issue is gone.
在podspec文件建立好以後pod install。
可是源碼根目錄
(Class目錄下)的空文件夾,不會自動被放到Xcode中。
//JSON::ParserError - A JSON text must at least contain two octets!
rm ~/Library/Caches/CocoaPods/search_index.json
複製代碼
//錯誤1 RuntimeError - [Xcodeproj] Unknown object version.
sudo gem install cocoapods --pre
//錯誤2 ERROR: While executing gem ... (Errno::EACCES)
// Permission denied @ rb_sysopen - /Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.5.7/LICENSE
sudo chmod -R 777 /Library/Ruby/Gems/
//錯誤3 ERROR: While executing gem ... (Gem::FilePermissionError)
// You don't have write permissions for the /usr/bin directory. sudo gem install -n /usr/local/bin cocoapods 複製代碼
find /Users/yangyang/.cocoapods/repos/master -iname libwebp
cd /Users/yangyang/.cocoapods/repos/master/Specs/1/9/2/libwebp
cd 0.6.1
修改libwebp.podspec.json
"source": {
"git": "https://chromium.googlesource.com/webm/libwebp",
"tag": "v0.6.0"
},
將其中的"git"對應的url替換爲https://github.com/webmproject/libwebp.git
複製代碼
也多是,沒有配好本地的https用戶名密碼。或阿里雲階段性抽風