创建pod 私库 && 更新私库

  1. 在服务器上创建一个git工程,如HubKit

  2. 使用pod命令创建swift工程,pod将自动帮你完成xcode的很多操作

    1
    pod lib create HubKit
  3. 修改第一步生成的HubKit.podspec文件,主要包括:
    s.summary
    s.homepage
    s.source 改成第一步的git路径
    增加 s.swift_version = ‘4.0’

  4. 将整个工程上传到第一个创建的git服务器

    1
    2
    3
    4
    5
    6
    git remote add origin https://git.dev.tencent.com/chenglini/HubKit.git
    git add .
    git commit -a -m "init"
    git push --set-upstream origin master
    git tag 0.1.0
    git push --tag
  5. 检查pod库

    1
    pod lib lint

如果有以下出错提示:

1
- ERROR | [iOS] unknown: Encountered an unknown error (Could not find a `ios` simulator (valid values: com.apple.coresimulator.simruntime.ios-12-2, com.apple.coresimulator.simruntime.tvos-12-2, com.apple.coresimulator.simruntime.watchos-5-2). Ensure that Xcode -> Window -> Devices has at least one `ios` simulator listed or otherwise add one.) during validation.

解决方案:更新pod

1
sudo gem install -n /usr/local/bin cocoapods

  1. 检查spec文件

    1
    pod spec lint
  2. 创建私库pod服务器,如podSpec

    1
    pod repo add PrivServer https://git.dev.tencent.com/chenglini/podSpec.git
  3. 创建私库并上传到私库服务器

    1
    pod repo push PrivServer HubKit.podspec --sources=https://git.dev.tencent.com/chenglini/podSpec.git
  4. 使用的时候,在podfile文件中加入

    1
    2
    3
    source 'https://git.dev.tencent.com/chenglini/podSpec.git'
    ...
    pod 'HubKit'

更新私库

  1. 更新代码,更新私库版本号,然后执行
    1
    pod lib lint --use-libraries --allow-warnings

如果pod依赖私有库,则提交私库到私有仓库的时候,可以使用

1
pod lib lint --sources=PrivServer

如果依赖多个私有库,则使用:

1
pod lib lint --sources=PrivServer,REPO_NAME2,REPO_NAME3,master

  1. 将代码提交到远程代码仓库,并设置tag为私库到新版本号

    1
    2
    git tag 2.0
    git push --tags
  2. 最后把修改过的本地索引加到cocoapods 的 master 的索引中去

    1
    pod repo push  PrivServer HubKit.podspec --use-libraries --allow-warnings
Contents
,