Create new file
并输入LICENSE
,点击右上角出现的Choose a license template
选择须要的证书并添加进去设置完成后直接克隆到本地,并将工程代码复制进该文件夹ios
cd xxx
pod spec create xxx
Alamofire
@version = "0.0.1" Pod::Spec.new do |s| s.name = "MCircleBoard" s.version = @version s.summary = "MCircleBoard" s.description = "MCircleBoard is a dash board." s.homepage = "https://github.com/MichaelLynx/MCircleBoard" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "xxx" => "xxxxxx@qq.com" } s.platform = :ios s.ios.deployment_target = "8.0" s.source = { :git => "https://github.com/MichaelLynx/MCircleBoard.git", :tag => "v#{s.version}" } s.source_files = "Code/*.swift" s.resources = ["Code/*.xcassets"] s.swift_version = "4.0" s.requires_arc = true s.framework = "UIKit" end
s.dependency "AFNetworking", '~> 3.0'
name
、version
、summary
、homepage
、license
、author
、deployment_target
、source
、source_files
、requires_arc
source_files
:最好把要上传的文件放在专门的文件夹下resource
\`resources\\
resource_bundles`spec里添加资源:git
spec.resource = 'Code/MCircleBoardIcon.bundle' spec.resources = ['Images/*.png', 'Sounds/*'] spec.resource_bundles = { 'YourBundleName' => ['MapView/Map/Resources/*.png'], 'OtherResources' => ['MapView/Map/OtherResources/*.png'] }
bundle内图片的调用方式:github
var bundle = Bundle(for: theClass.self) if let resoucePath = bundle.path(forResource: "bundleName", ofType: "bundle"), let resouceBundle = Bundle(path: resoucePath) { bundle = resouceBundle } let image = UIImage(named: imageName, in: bundle, compatibleWith: nil) ?? UIImage()
theClass
:工程项目名称;bundleName
:对应的bundle的名字podspec字段说明:swift
字段 | 做用 |
---|---|
name | 库的名称 |
version | 版本号,该号必定要和GitHub上的对应,参见下面的步骤 |
summary | 该库的一个简介 |
homepage | 这个库的主页,对应Github上的地址 |
license | 采用何种license,和建立GitHub时候选择的那个要对应 |
author | 做者 |
deployment_target | 可使用该库的iOS的最低版本 |
source | 数据源,对应的是你clone 的时候使用的那个HTTPS 的连接地址 |
source_files | 哪些文件是要上传到pods的 |
requires_arc | 是否在ARC环境下使用 |
dependency | 该库还引用了哪些第三方库 |
Tag version
以v开头,后接版本号,标题release title
须要填写若是已经注册成功帐号,则这步跳过
在终端输入指令:ruby
pod trunk register 邮箱地址 '用户名' —description='描述信息' 或 pod trunk register 邮箱地址 '用户名' --verbose
验证成功后在终端输入如下命令确认是否注册成功ui
pod trunk me
若是确认podspec文件没问题则能够不进行验证若是配置得正确,则输入验证命令后会提示:
passed validation.
code
podspec文件配置完成以后能够在终端输入指令进行验证orm
pod spec lint XXX.podspec
XXX.podspec
可省略pod lib lint
只从本地验证你的pod可否经过验证;pod spec lint
从本地和远程验证你的pod可否经过验证。pod lib lint
可省略,直接用pod spec lint
进行验证输入如下指令将代码上传到cocoapods:图片
pod trunk push
若是以前验证的结果里有warning
,则能够用--allow-warnings
忽略警告:ip
pod trunk push --allow-warnings
完成后出现Tell your friends
字样则证实上传完毕,能够经过pod search XXX
指令来验证是否上传成功。
若是没搜索出来则能够经过pod repo update
更新本地的pod库,而后再进行搜索。
若是事先已经下载了旧版的库,能够直接cd到该工程,并pod update 第三方库名
,哪怕暂时没法搜索出来,pod update
依然能够有效将其更新到最新版本。
如下是我本身建立的第三方库,欢迎点个Star,也欢迎相互交流。
MCircleBoard