天天看點

016-Cocoapods私有庫制作 及 普通項目引入個人私有庫 注意點

前提:假設你本地已經安裝好cocoapods環境

私有庫制作

1.建立項目

pod lib create 項目名稱      

2.git/gitee(推薦gitee)建空倉庫

a.擷取遠端倉庫位址

b.git clone URL到本地磁盤

c.把 b clone到本地的.git目錄copy到1建立的項目根目錄下

d.把 upload.sh腳本copy到1建立的項目根目錄下(如下是示例腳本)

3.在 1 建立的項目裡新增Object-C/Swift 工具類或元件

4.終端裡執行upload.sh腳本直至 私有庫 送出到git倉庫 并且 同步私有索引庫成功

5.注意 pod lib create 項目名-項目名稱裡不要有奇葩的特殊符号 - / _ 都不行

6.swift私有工具類 或者 庫裡函數、屬性變量要是允許外抛 勿忘添加 public關鍵詞,要是 swift 允許 Object-C 通路 勿忘添加 @objc

普通項目引入個人私有庫

1.普通項目Podfile示例如下

# 私有索引庫位址
source 'https://gitee.com/nixs/nispec.git'
# github公有索引庫位址
source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '10.0'
target 'swift002' do
use_frameworks!
# 屏蔽所有第三方架構警告
inhibit_all_warnings!

#注意如下格式
#pod 'lib', : git => 'url', :tag => 'version'
#注意:隻能使用 “  => ” 符号;

#pod 'NIUIToolsPodSwift', :git => 'https://gitee.com/nixs/niuitools-pod-swift.git', :tag => '0.1.2'
pod 'NIUIToolsPodSwift','0.1.2'
pod 'NIUIToolsPod'

# 更改所有第三方架構 Target 版本
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'