iOS made cocoapods library

Create a project

In githubcreating the warehouse, as shown in FIG.

Note: Select Add a certificate, create a pod behind the library when the need to use.

Cloning project to the local

Here I use an existing project directly to practice hand, is not built.

Use terminal performs git clone https://github.com/ZpFate/TFKit.gitcommand or code Source Tree cloned into local use other tools.

Create a file podspec

Cloned into the local warehouse to the next directory, execute pod spec create TFKitthe command

Create a file podspec

Edit podspec file

Use vscodethe command to open the file for editing podspec

Pod::Spec.new do |s|

  # 库名称
  s.name         = "TFKit"

  # 库的版本
  s.version      = "0.0.1"

  # 库摘要
  s.summary      = "iOS开发中一些常用的基类与类目工具"

  # 库描述(最好比summary多写一些描述)
  s.description  = <<-DESC
                    iOS开发中一些常用的基类与类目工具, 有AES加密, 字符串处理等
                   DESC

  # 远程仓库地址,即 GitHub 的地址,或者你使用的其他的 Gitlab,码云的地址
  s.homepage     = "https://github.com/CircusJonathan/CJChartView"

  # MIT许可证(The MIT License),软件授权条款
  s.license      = "MIT"
  # s.license      = { :type => "MIT", :file => "FILE_LICENSE" }

  # 作者信息
  s.author             = { "Jonathan" => "[email protected]" }

  # 支持的系统及支持的最低系统版本
  s.platform     = :ios
  s.platform     = :ios, "8.0"

  # 支持多个平台使用时
  # s.ios.deployment_target = "8.0"
  # s.osx.deployment_target = "10.7"
  # s.watchos.deployment_target = "2.0"
  # s.tvos.deployment_target = "9.0"

  # 下载地址,即远程仓库的 GitHub下载地址(clone 地址),使用.git结尾
  s.source       = { :git => "https://github.com/ZpFate/TFKit.git", :tag => "#{s.version}" }

  # 当前目录是podspec文件所在的目录
  # 等号后表示的是要添加 CocoaPods 依赖的库在项目中的相对路径
  # “**”这个通配符代表  s.source_files  = "TFKit-OC/TFKit-OC/TFKit/*"
  # 次级文件夹
  s.subspec 'TF_Category' do |ss|
  ss.source_files = 'TFKit-OC/TFKit-OC/TFKit/TF_Category/*'
  end

  s.subspec 'TF_BaseClass' do |ss|
  ss.source_files = 'TFKit-OC/TFKit-OC/TFKit/TF_BaseClass/*'
  end

  # 指明文件夹下不需要添加到 CocoaPods 的文件
  # 这里是 Exclude 文件夹内的内容
  s.exclude_files = ""

  # 是否需要项目是 ARC
  s.requires_arc = true

  # 库中用到的框架或系统库(没用到可以没有)
  s.ios.frameworks = 'Foundation', 'UIKit'
  # s.framework  = ""
  # s.frameworks = "", ""

  # 如果你的库依赖其他的 Podspecs,可以添加这些依赖项,例如
  # s.dependency 'AFNetworking', '~> 3.2.1'

end
复制代码

Verify podspec file

Continue to execute commands in the current directory

pod spec lint
复制代码

Wait for a moment, the above error, is performed in the terminal

sudo gem install cocoapods
复制代码

After the upgrade is complete verification command execution

Verification success flag:

Published pod

If you have not registered pod need to register using the following command

pod trunk register [email protected] "username"
复制代码

After successful registration, execute the following command in the terminal release pod:

pod trunk push TFKit-OC.podspe
复制代码

Published pod

Successfully posted

After successfully posted to but not through the pod search

After the successful release show, use the pod searchcommand displays:

pod search failed

An input terminal

rm ~/Library/Caches/CocoaPods/search_index.json
复制代码

After the completion of the search

pod search TFKit-OC
复制代码

search results

Reproduced in: https: //juejin.im/post/5d09f2a25188252b8d1d452a

Guess you like

Origin blog.csdn.net/weixin_34318272/article/details/93179805