1、创建 Repo
$ pod repo add REPO_NAME SOURCE_URL
$ pod repo push REPO_NAME SPEC_NAME.podspec
2、删除 REPO
pod repo remove [name]
二、创建 仓库 Spec。
1、
pod lib create SPEC_NAME
例如:
pod lib create
DDJSON.podspec
2、修改 *****.podspec
#
# Be sure to run `pod lib lint DDJSON.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a
# are optional, but their use is encouraged
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'DDJSON'
s.version = '0.1.0'
s.summary = 'DDJSON.'
# 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!
s.description = <<-DESC
DESC
s.homepage =
# s.screenshots =
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { ‘***' => }
s.source = { :git => :tag => s.version.to_s }
# s.social_media_url =
s.ios.deployment_target = '7.0'
# 重点要修改,默认的 s.source_files = 'DDJSON/**/*’,会报 “undefined method `path' for nil:NilClass
”错误。
s.source_files = 'DDJSON/**/*.{c,h,hh,m,mm}'s.public_header_files = 'DDJSON/**/*.h'
# s.resource_bundles = {
# 'DDJSON' => ['DDJSON/Assets/*.png']
# 数据库文件必须要加载 resource 里面,否则 pod install 不会加载到。
'DDUserTracking' => ['DDUserTracking/*.{xcdatamodeld,xcdatamodel}']
# }
# s.frameworks = 'UIKit', 'MapKit'
# CoreData 必须添加引用。
s.frameworks = 'Foundation', 'CoreData','UIKit'
# s.dependency 'AFNetworking', '~> 2.3'end
3、验证
pod lib lint
遇到的问题:
1)“- ERROR | [iOS] unknown: Encountered an unknown error (undefined method `path' for nil:NilClass) during validation.”
IMO this is a configuration error, although we should handle it more gracefully. It's a configuration error because we're saying that a resource is a source file, which it's not. The easy fix here is to change s.source_files = 'Pod/Classes//'
to be something like s.source_files = 'Pod/Classes//.{c,h,hh,m,mm}'.
2)``“Encountered an unknown error (Simulator iPhone 4s is not available.) during validation.”``
升级 cocoapods,“sudo gem install -n /usr/local/bin cocoapods”
4、发布
# 发布到 github。
$ pod trunk register orta@cocoapods.org 'Orta Therox' --description='macbook air’
# 发布到私有库
pod repo push REPO [NAME.podspec].
# Adding other people as contributors
$ pod trunk add-owner ARAnalytics kyle@cocoapods.org
5、私有库 中 引用私有库
即在Podspec
文件中依赖(dependency)私有库
这种情况就比较麻烦一点,因为毕竟Podspec
文件中并没有指明私有仓库地址的地方。那么肯定就不在Podspec
文件里面指明私有仓库的地方。而是在验证和上传私有库的时候进行指明。即在下面这两条命令中进行指明:
pod lib lint 项目名.podspec
pod repo push REPO 项目名.podspec
6、删除某一个 podspec
只需要到私有REPO 目录下删除 podspec 即可
cd ~/.cocoapods/repos/DDSpecs
rm -Rf PodTestLibrary
# 任何推送到远端
git add —all .
git ci -m
"remove unuseful pods"
git push origin master