首先管理好cocoapods
cocoapods最新版的话,podspec文件里面的内容就是spec开头的,cocoapods不是最新版的话,就是s开头的。
cocoapods升级
- sudo gem install cocoapods
- 然后提示输入密码,即电脑开机密码,输入完毕后按回车键即可。
- 然后发现报错
ERROR: Could not find a valid gem ‘cocoapods’ (>= 0), here is why:
Unable to download data from https://gems.ruby-china.org/ - bad response Not Found 404 (https://gems.ruby-china.org/specs.4.8.gz)
即提示无法从https://gems.ruby-china.org/下载镜像文件 - 在 google 上面找到解决方案
将https替换成http
sudo gem sources -r https://rubygems.org
sudo gem sources -a http://rubygems.org
- ~ sudo gem sources -r https://rubygems.org/
Password:输入开机密码
source https://rubygems.org/ not present in cache - ~ sudo gem sources -a http://rubygems.org
https://rubygems.org is recommended for security over http://rubygems.org - Do you want to add this insecure source? [yn] y
- http://rubygems.org added to sources
这样就将源镜像文件替换为http了,然后再安装cocoapods 即可 - sudo gem install cocoapods
- 出现 While executing gem … (Gem::FilePermissionError)
You don’t have write permissions for the /usr/bin directory.
改为 sudo gem install -n /usr/local/bin cocoapods 即可
最后出现gems installed - pod --version
至此cocoapods升级成功。
安装完后别忘了把它设回来: - sudo gem sources -r http://rubygems.org
sudo gem sources -a https://rubygems.org
发布到github用cocoapods管理
仓库搭建
- github上创建一个仓库 然后可以用sourcetree 进行代码管理
- 这是sourcetree界面,点击新建从url克隆,url写github里面的那个download的http链接就行了
- 新建github仓库时,那个liencese 需选择一个可以是MIT,不然在检验podspec文件会出现sourcesfile检验不过
工程搭建
- 新建一个项目工程或者新建一个文件夹放一个轮子的一些.h或者.m文件
*上图的.podspec文件的生成是:可参考 -
cd 到(AESpods的文件路径)
pod spec create AESpods
spec.name = "AESpods"
spec.version = "1.0.0"
spec.summary = "A FirstPods Demo For iOS"
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
spec.description = <<-DESC
Help developer to quickly A FirstPods Demo
DESC
spec.homepage = "https://github.com/2672405704/AESpods"
# spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See https://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
#
spec.license = "MIT"
# spec.license = { :type => "MIT", :file => "FILE_LICENSE" }
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
#
spec.author = { "pengming" => "2672405704@qq.com" }
# Or just: spec.author = "pengming"
# spec.authors = { "pengming" => "2672405704@qq.com" }
# spec.social_media_url = "https://twitter.com/pengming"
# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
#
# spec.platform = :ios
# spec.platform = :ios, "5.0"
# When using multiple platforms
# spec.ios.deployment_target = "5.0"
# spec.osx.deployment_target = "10.7"
# spec.watchos.deployment_target = "2.0"
# spec.tvos.deployment_target = "9.0"
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
#
spec.source = { :git => "https://github.com/2672405704/AESpods.git", :tag => "1.0.0" }
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#
spec.source_files = "AESFile", "AESFile/**/*.{h,m}"
# spec.exclude_files = "Classes/Exclude"
# spec.public_header_files = "Classes/**/*.h"
# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#
# spec.resource = "icon.png"
# spec.resources = "Resources/*.png"
# spec.preserve_paths = "FilesToSave", "MoreFilesToSave"
# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#
# spec.framework = "SomeFramework"
# spec.frameworks = "SomeFramework", "AnotherFramework"
# spec.library = "iconv"
# spec.libraries = "iconv", "xml2"
# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.
# spec.requires_arc = true
# spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# spec.dependency "JSONKit", "~> 1.4"
- 上述里面的tag尽量与version相同
- 可以用
-
git tag ‘1.0.0’
git push --tags
git push origin master - 可在github的界面点击master查看
- 然后校验一些。
pod lib lint AESpods.podspec —verbose
- 没问题的话就发布
pod trunk push AESpods.podspec
- 成功后 要等接近1个小时 执行pod search AESpods可以查一下。