项目优化

iOS 制作一个pod私有库

2021-01-18  本文已影响0人  落夏简叶

期望:用XXPrivateRepos作为一个私有仓库,用来管理一些小的组件(或称模块)(如:XXUI

一 、 在github上添加一个私有仓库(这里报红是因为已经创建才截的图)

image.png

现在我们再添加一个仓库 XXPrivateRepos

pod repo add XXPrivateRepos https://github.com/shine93/XXPrivateRepos.git

添加完毕后文件夹下就多了一个目录。


image.png

二 、创建一个库,打标签

  1. 在github上创建一个私有库XXUI作为一个小组件。

    image.png
  2. 终端cd到保存私有库的目录下, pod lib create XXUI

    image.png
  3. 回答制作库的几个问题

image.png

[!] XXUI did not pass validation, due to 1 warning (but you can use --allow-warnings to ignore it).
You can use the --no-clean option to inspect any issue.
解决:
pod lib lint --allow-warnings

再远程lint
pod spec lint --allow-warnings

三 、推送要加入的库.podspec到git私有仓库中

四 、创建一个demo,pod使用这个私有仓库

加上source后:


image.png
import UIKit
import XXUI

class ViewController: UIViewController {

    @IBOutlet weak var nameLabel: InsetLabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        nameLabel.layer.cornerRadius = 5
        nameLabel.layer.masksToBounds = true
        nameLabel.textInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)
    }
}

参考:
我的制作库系列之: iOS制作一个pod公开库文档
我的制作库系列之: iOS 制作本地库Development Pods
cocoapods制作库的文档
cocoapods制作Private Pods文档
cocoapods制作公开Pods文档

上一篇 下一篇

猜你喜欢

热点阅读