-
StackOverflow 文档
-
cocoapods 教程
-
用 Github 创建你的第一个 Pod
-
用 Github 创建你的第一个 Pod
打开回购
- 创建新的仓库 (我的建议首先在临时仓库上添加 pod,然后再添加到原始项目中)
- 使用你的回购名称填充存储库名称。我将在本教程中使用
myrepo,并将“<”和“>”符号用于你应该更改为自己的部分。
- 单击使用自述文件初始化此存储库
- 添加许可证。我将在本教程中使用
MIT。
将你的回购拉到本地
- 开放式终端。
- 去你的回购地点
cd </your/path/<myrepo> 或用 cd </your/path> 创建它。mkdir <myrepo>。cd <myrepo>
- 使用
git init 将 git 添加到你的文件夹中
- 将你的回购链接与
git remote add origin https://github.com/<username>/<myrepo>.git 链接。 (你可以检查它是否与 git remote -v 一起工作(不是 git remove -v))
- 用
git pull 从 github 中取出你的回购
- 类型:git pull origin master
- 输入 git commit
添加 Cocoapods
- 安装 cocoapods:
sudo gem install cocoapods。写 pod --help 来检查它是否正常工作。 (如果你已经有 cocoapods,请跳过)
- 用
touch <myrepo>.podspec 创建 <myrepo>.podspec
- 用编辑器打开
<myrepo>.podspec。使用 Xcode 或 Sublime Text。
- 粘贴以下内容。你可以查看这个例子 。有关详细信息,请查看文档
Pod::Spec.new do |s|
s.name = "<myrepo>"
s.version = "0.1"
s.summary = "<My summary>"
s.description = "<MUST BE LONGER THAN SUMMARY>"
s.homepage = "https://github.com/<username>/<myrepo>"
s.license = 'MIT'
s.author = { "<username>" => "<useremail>" }
s.source = { :git => "https://github.com/<username>/<myrepo>.git", :tag => s.version.to_s }
s.platform = :ios, '8.0'
s.requires_arc = true
# If more than one source file: https://guides.cocoapods.org/syntax/podspec.html#source_files
s.source_files = '<myrepo>.swift'
end
- 把
pod lib lint <myrepo>.podspec 写到终端。如果你有任何错误,请写下 pod lib lint <myrepo>.podspec --verbose。解决你的错误(解决你的错误可能需要一些时间在这里无法帮助)。
- 使用
git add . 将新更改添加到 git,然后使用 git commit -m "Added pods" 进行提交
- 使用
git push 将更改推送到远程仓库
- 创建新版本 https://github.com/ / Click Releases - >单击新版本
- 将“0.1”写入标签版本。 (可选你可以填写发布标题)。确保版本与
<myrepo>.podspec 内的 s.version 相同
- 写
pod trunk register name@example.org 'Your Name' --description='macbook pro'
- 在你的新发布后打开终端并写下
pod trunk push <myrepo>.podspec。这将改变 CocoaPods 规范 ,这将使你能够在 podfile 内写入 pod '<myrepo>'