1、提交代码到github
1)在github添加远程仓库
2)将本地代码提交到远程仓库
git remote add origin 远程仓库地址
git pull origin master --allow-unrelated-histories
git branch --set-upstream-to=origin/master master
git add .
git commit -m "添加本地代码到远程仓库"
git push
3)设置仓库的版本(打tag必须设置版本,后面会用到)
git tag -m "首次提交" "1.0"
git push --tags
git add .
git commit -m "first commit"
git remote add origin https://github.com/tiancanfei/ADDeviceTool.git
git push -u origin master
可能出的错误及解决办法:
fatal: refusing to merge unrelated histories
git pull origin master --allow-unrelated-histories
//git pull和git fetch的不同
http://blog.csdn.net/wfdtxz/article/details/8632811
2、构建podspec文件
1)创建.podspec文件
touch 项目名称.podspec
2)编辑.podspec文件
Pod::Spec.new do |s|
s.name = "仓库名称"
s.version = "版本号"
s.summary = "概述"
s.description = <<-DESC
详细描述
DESC
s.homepage = "github仓库网址(区别仓库地址https://github.com/*****/*****)"
s.license = "MIT"
s.license = { :type => "MIT", :file => "LICENSE" }
s.author = { "作者名称" => "邮箱地址" }
#支持平台
s.platform = :ios
#支持平台版本,如果是swift版本必须是>8.0的
s.platform = :ios, "7.0"
#仓库地址 (不要使用ssh)
s.source = { :git => "https://github.com/*****/****.git", :tag => "#{s.version}" }
#源文件位置
s.source_files = "ADCarouselView/ADCarouselView/*.{h,m}"
# s.exclude_files = "Classes/Exclude"
#仓库地址 (暴露出来的头文件,如果是swift就不需要这行,swift没有头文件)
s.public_header_files = "ADCarouselView/ADCarouselView/*.h"
#需要的framewoke
# s.framework = "UIKit"
s.frameworks = "UIKit"
#库
# s.library = "iconv"
# s.libraries = "iconv", "xml2"
#是否arc
s.requires_arc = true
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
#需要依赖的三方
#s.dependency 'SDWebImage', '~> 3.7.6'
end
3)验证.podspec文件(输出仓库passed validation表明成功,不能又任何警告错误,否则可能无法成功添加仓库)
pod lib lint --allow-warnings --use-libraries
3、trunk检测(这里使用trunk方式添加仓库)
pod trunk me
如果能输出你的账号信息即可
如果出现
Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.
那么注册一下
pod trunk register 邮箱地址 "作者名称"
(这里的邮箱可以随便填,163好像收不到邮件)
4、提交代码到cocoapod仓库
提交到cocoapod仓库了
pod trunk push *.podspec --allow-warnings --use-libraries
提交成功显示如下
🎉 Congrats
🚀 仓库名称 (版本号) successfully published
📅 February 7th, 21:33
🌎 https://cocoapods.org/pods/仓库名称
👍 Tell your friends!
提交成功后可以在
https://github.com/CocoaPods/Specs/tree/master/Specs
查看到刚刚提交的记录
在几个小时以后可以尝试在
https://cocoapods.org/
搜索要是能搜到那么仓库已经审核成功了
此时就可以直接像使用其他三方库一样使用podfile来添加模块(但此时我在terminal搜索到我们的库,查看了下https://github.com/CocoaPods/Specs/tree/master/Specs
的提交历史,好像得三天以后才可以搜索到)
如果仍然pod serach不到尝试
1、pod setup更新仓库
2、删除搜索记录
rm /Users/targetcloud/Library/Caches/CocoaPods/search_index.json`后再搜索
3、重新搜索
5、更新cocoapod仓库
1)先打tag,并提交到github
2)修改*. podspec文件中的version版本号
3)重新push
pod trunk push *.podspec 即可(版本相同push将会失败)
6、xcode8错误
- ERROR | [iOS] unknown: Encountered an unknown error (Simulator iPhone 4s is not available.) during validation
直接更新cocoapod即可
sudo gem install -n /usr/local/bin cocoapods
7、使用static libriaries错误(--use-libraries)
ERROR | [iOS] Encountered an unknown error (The 'Pods' target
has transitive dependencies that include static binaries: (......)
during validation.
8、使用依赖,请使用import <>