部分参考了使用 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用户名密码。或阿里云阶段性抽风