看了各种文档
按照上面的顺序 我们一个个步骤进行操作 1.创建pod仓库 例:https://github.com/IMKiller/GHSpecs.git ![]() image.png 本地创建私有的 repo 仓库 创建一个私有Spec Repo,私有仓库列表就是一个普通的空的git仓库(后面会添加内容的),在你们的git服务器上面创建一个新的仓库就行,不需要里面有任何文件,然后你可以拿到你的git仓库的一个地址,比如我创建的就是 https://github.com/IMKiller/GHSpecs.git ,然后在终端下执行命令,将新创建的私有仓库添加到本地Pods里面,这样就相当于使用pod的时候多了一个仓库列表,多了一个数据源。 pod repo add GHSpecs https://github.com/IMKiller/GHSpecs.git 执行命令之后,我们可以打开本地的 repo 查看私有的库是否创建成功,使用如下命令: cd ~/.cocoapods/repos 记得在Git https://github.com/IMKiller/GHSpecs.git ![]() image.png 2. 创建Pod的所需要的项目工程文件,并且有可访问的项目版本git地址 这个步骤的目的:创建我们的模块项目(一般是一个可运行的demo,个别比较特殊的只有模块的文件),把模块的文件按照真实文件夹放好,并且上传到git服务器,得到git地址。(附带可以在这一步创建后面所需要的podspec文件和license文件) $ pod lib create GHTest 这里会创建一个名为GHTest的项目,里面包含了我们下面要用到的podspec文件和license文件,可以对项目进行修改,变成我们想要的样子。 填写完我们需要创建的swfit版本,但是demo无法跑起来 原因 在buildSetting中进行设置’ ![]() image.png 3. 创建并修改Pod所对应的podspec文件 # # Be sure to run `pod lib lint GHTest.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./syntax/podspec.html # Pod::Spec.new do |s| s.name = 'GHTest' s.version = '0.1.0' s.summary = 'A short description of GHTest.' # 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/IMKiller/GHTest' #主页,这里要填写可以访问到的地址,不然验证不通过 # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' s.license = { :type => 'MIT', :file => 'LICENSE' } s.author = { 'IMKiller' => '872729086@qq.com' } s.source = { :git => 'https://github.com/IMKiller/GHTest.git', :tag => s.version.to_s } # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>' s.platform = :ios, '9.0' #支持的平台及版本 s.source_files = 'GHTest/Classes/**/*' #代码源文件地址,**/*表示Classes目录及其子目录下所有文件, #如果有多个目录下则用逗号分开,如果需要在项目中分组显示,这里也要做相应的设置 # s.resource_bundles = { # 'GHTest' => ['GHTest/Assets/*.png'] # } # s.public_header_files = 'Pod/Classes/**/*.h' #所需的framework,多个用逗号隔开 s.frameworks = 'UIKit' #所需的framework,多个用逗号隔开 #依赖关系,该项目所依赖的其他库,如果有多个需要填写多个s.dependency # s.dependency 'AFNetworking', '~> 2.3' end
4. 本地测试配置好的podspec文件是否可用 $ pod lib lint 如果有错误根据提示修改就好了,一般来说问题不大, pod lib lint --allow-warnings 5. 提交项目和podspec配置到Git仓库,并打标签
git上传完成后 这里因为我们私有pod给的版本号就是0.1.0 ![]() image.png ![]() image.png ![]() image.png 之后进行验证 podspec 文件
**验证库** // 验证本地库 pod lib lint // 验证远程库 pod spec lint // 忽略警告 --allow-warnings // 打标签 git tag '0.1.0' git push --tags // 删除标签 git tag git tag -d 0.1.0 git tag git push origin :0.1.0 git tag 0.1.0 git push --tags 很多命令这个里面写的很全 6. 向私有的Spec Repo中提交podspec 完成这一步就可以使用pod install命令进行安装了 只有将podspec文件提交到仓库列表后才能像平常一样使用pods安装管理,不过因为是私有的仓库列表,换台机器要重新添加仓库列表 pod repo push [repo] [podspec] --verbose --allow-warnings ![]() image.png 远端的仓库也有这个了 ![]() image.png
7. 在个人项目中的Podfile中增加刚刚制作的好的Pod并使用 source "https://github.com/IMKiller/GHSpecs" ![]() image.png 8. 更新维护podspec 私有库也是会更新的,基本上都是把更新后的内容push到远端git服务器,然后重走5和6的步骤,重新打标签,重新推送到pod仓库列表,然后在项目里面pod install或者pod update |
|
来自: shawnsun007 > 《软件开发》