cocoapod制作私有库repo

闲来没事,整理好久之前的文档。制作私有库和公共库还是有一定的差别的。甚至还有快速模式,后面给大家展开叙述

1:创建两个远程仓库

  1. 创建ios_spece远程仓库,用来存放本地podspec。
  2. 创建podProject远程仓库,用来存放项目工程文件。

2:处理ios_spece远程仓库

前往文件夹 ~/.cocoapods/repos

打开终端,在终端切换到当前目录下,然后进行pod repo add操作

在终端输入:

pod repo add ios_spece https://gitee.com/whuizhou/i-os_speace.git
(1中创建的ios_spece远程仓库的地址)

3:创建pod的项目工程

创建pod工程

3.1 修改podspec文件

Pod::Spec.new do |s|
  s.name             = 'shareSDK'
  s.version          = '1.0.0'
  s.summary          = 'SHARE-SDK'

  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC

  s.homepage         = 'https://gitee.com/whuizhou'
  
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { '大哥还是当年的大哥' => 'wangh@email.com' }
  s.source           = { :git => 'https://gitee.com/whuizhou/repo-share-p.git', :tag => s.version.to_s }
  #*** 这里一定要修改为工程的git地址

  s.ios.deployment_target = '9.0'

  s.source_files = 'shareSDK/Classes/**/*'
  
  # s.resource_bundles = {
  #   'shareSDK' => ['shareSDK/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking'
   s.dependency 'SDWebImage'
end

设置初始版本为1.0.0
引用了SDWebImage

3.2 校验本地podspec文件

到工程的目录下,验证podspec文件

pod lib lint shareSDK.podspec --allow-warnings --verbose

验证结果
 ** BUILD SUCCEEDED **

   Testing with `xcodebuild`.
 -> shareSDK (1.0.2)
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | xcodebuild:  note: Building targets in parallel
    - NOTE  | xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | xcodebuild:  note: Build preparation complete
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Analyzing workspace
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - WARN  | xcodebuild:  /Users/zzg/Library/Developer/Xcode/DerivedData/App-gjchcgjwyytzwnbeodicecfxkczb/Build/Products/Release-iphonesimulator/shareSDK/shareSDK.framework/Headers/shareSDK-umbrella.h:13:9: warning: double-quoted include "LogTool.h" in framework header, expected angle-bracketed instead [-Wquoted-include-in-framework-header]
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')

shareSDK passed validation.

3.3 本地文件上传到远程仓库中,并打对应的tag号

  1. 上传本地工程到远端仓库
  2. tag版本号,一定要与s.version 一致
s.version          = '1.0.0'

打tag

// 打tag号
git tag -m "1.0.2标签" -a 1.0.2
// 推送tag
git push --tags
// 查看tag
git tag
  1. 检验podspecs文件的有效性
pod lib lint /Users/zzg/Desktop/SHARE/shareSDK.podspec --use-libraries --allow-warnings

校验结果如下

-> shareSDK (1.0.2)
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | xcodebuild:  note: Building targets in parallel
    - NOTE  | xcodebuild:  note: Using codesigning identity override: -
    - NOTE  | xcodebuild:  note: Build preparation complete
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Analyzing workspace
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')

shareSDK passed validation.

4:向私有的ios_space远程仓库提交podspec

pod repo push ios_speace shareSDK.podspec --sources='https://gitee.com/whuizhou/i-os_speace.git,https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git' --use-libraries --allow-warnings --verbose

如果引用的有其他第三方库,或者其他私有地址一定要在后面写上

source='地址' --use-libraries --allow-warnings --verbose

这里用的是清华源

5:使用自己的私有库

在工程的podfile文件的头一行里写

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
source "https://gitee.com/whuizhou/i-os_speace.git"

完成podfile文件如下

source 'https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git'
source "https://gitee.com/whuizhou/i-os_speace.git"


target 'dddd' do
    platform :ios, '9.0'
    pod 'shareSDK', '~> 1.0.2'


end

如果觉得可以还可添加“洲洲哥”的微信公众号,随时获取

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 想做组件化,需要用CocoaPod 远程私有仓库,在此记录一波.一 .首先建立两个远程仓库1)存放pod 索引文件...
    我是C阅读 1,607评论 0 4
  • 为了利用Cocoapod的进行私有仓库管理/打包/切换源码的功能,我们按照下图的规划一步一步进行实现 如何搭建一个...
    奚山遇白阅读 980评论 0 0
  • 今天正好项目需要,实战一下,在此记录,根据官方文档https://guides.cocoapods.org/mak...
    dongfang阅读 686评论 0 0
  • 步骤 创建一个spec Repo的私有远程仓库[A] , 一个存放pod 库源码的远程仓库[B],两个仓库! 创建...
    CoderKK阅读 525评论 0 1
  • 16宿命:用概率思维提高你的胜算 以前的我是风险厌恶者,不喜欢去冒险,但是人生放弃了冒险,也就放弃了无数的可能。 ...
    yichen大刀阅读 6,120评论 0 4