1、利用pod創(chuàng)建項目
pod lib create PPKit
這時候的生成工程目錄為

目錄.png
編寫podspec文件
#
# Be sure to run `pod lib lint PPKit.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 https://guides.cocoapods.org/syntax/podspec.html
#
Pod::Spec.new do |s|
s.name = 'PPKit'
s.version = '0.0.1'
s.summary = 'A short description of PPKit.'
# 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
TODO: Add long description of the pod here.
DESC
s.homepage = 'https://github.com/maple1994/PPKit'
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'maple1994' => '305554601@qq.com' }
s.source = { :git => 'https://github.com/maple1994/PPKit.git', :tag => s.version.to_s }
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
s.ios.deployment_target = '8.0'
s.source_files = 'PPKit/Classes/**/*'
# s.resource_bundles = {
# 'PPKit' => ['PPKit/Assets/*.png']
# }
# s.public_header_files = 'Pod/Classes/**/*.h'
# s.frameworks = 'UIKit', 'MapKit'
# s.dependency 'AFNetworking', '~> 2.3'
end
可以看到我們指定source_files指定在PPKit/Classes文件夾下的所有文件,所以我們的源碼都放在這里就可以了
2、上傳代碼到pod
podspec文件編輯好后,我們就可以上傳該文件到pod上了,進入podspec同級目
pod trunk push
如果之前沒有注冊pod賬號的,先注冊/登錄也是執(zhí)行以下指令
pod trunk register 305554601@qq.com 'maple'
3、私有庫
私有庫跟公有庫最大的區(qū)別就是,podspec的文件擺放位置。如果podspec文件都上傳到github上的 https://github.com/CocoaPods/Specs,所以如果我們想搭建私有庫,我們也要在自己的倉庫搭建一個專門存放specs文件的地方。那么我們上傳spec文件的時候,就要添加倉庫和推送指定的倉庫
// 添加
pod repo repoName git@git.xxx.xxx:iOSPods
// 推送
pod repo push repoName xxx.podspec
更詳細(xì)的內(nèi)容可以參考
http://www.cocoachina.com/articles/26210