Pod建立私有库

2019-02-28  本文已影响0人  kevin元

# 建立私有库

> 需要两个github库,一个是索引库,一个为代码库

***

## 建立索引库

1. github上建立repo(建private可能无影响)

2. 建立本地索引库,并和远程连接(此处需要讲本地库 push到github)

```

pod repo add KYPrivatePod https://github.com/kevinKyZheng/KYCocoaPods.git

```

注意点

    > 本地库地址 /Users/ios/.cocoapods/repos/KYPrivatePod

    > url不能写成代码库,否则错误如下

    ```

    [!] An unexpected version directory Assets was encountered for the /Users/zhangjian/.cocoapods/repos/mariclezhang/YTVestSDK Pod in the YTVestSDK repository.

    ```

## 建立代码库

1. 执行

```

$ pod lib create ZJMaricle

```

2. 修改spec文件,并执行 pod lib lint --allow-warnings

3. 检测通过后,在github建立代码库,并将本地库连接过去

4. 为repo打tag

```

git tag -m "" 0.1.0

git push --tags

```

**注意:此处的tag一定要和spec中的version相同,否则会出现如下错误**

```

fatal: Remote branch 0.0.1 not found in upstream origin

```

5. 将项目中的spec文件push到索引库管理

```

pod repo push KYPrivate  KYPrivate.podspec --allow-warnings

//pod repo push '索引库的名字' '代码库中spec文件的路径' --allow-warnings

```

## 私有库的使用

1. 在podfile文件中添加私有库的url

```

source 'https://github.com/CocoaPods/Specs.git'  #官方仓库的地址

source 'https://github.com/kevinKyZheng/KYCocoaPods.git'

```

## 常用命令

```

//查询私有库是否成功上传

pod search '私有库的名字'

//删除本地私有库

pod repo remove PodTest

//添加私有库

pod repo add PodTest https://github.com/kevinKyZheng/PodTest.git

//将代码库中的spec文件推送到索引库

pod repo push KYSIOSShared KYSIOSShared.podspec

//代码检查

pod lib lint

```

上一篇 下一篇

猜你喜欢

热点阅读