集成自己独有的pod,并发布到CocoaPods trunk,以及提交podspec 文件遇到的 error

大体步骤可以总结为以下几行命令

pod spec create JHDynamicFont
git tag -m"pod spec" "0.0.1"
git push origin --tags
pod trunk register 807880748@qq.com 'jinghao' --description='ios developer' --verbose
pod lib lint --allow-warnings
pod trunk push JHDynamicFont.podspec --allow-warnings
  • podspec文件设置如下
Pod::Spec.new do |s|

  s.name         = "JHDynamicFont"
  s.version      = "0.0.1"
  s.summary      = "通过为UIFontDescriptor添加category方法实现动态改变指定控件(如UILabel UIButtonLabel等)的字体大小。"
  s.description  = <<-DESC
  通过为UIFontDescriptor添加category方法实现动态改变指定控件(如UILabel UIButtonLabel等)的字体大小!!!
                   DESC

  s.homepage     = "https://github.com/Shenjinghao/JHDynamicFont"
  # s.screenshots  = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"

  s.license      = "MIT"
  # s.license      = { :type => "MIT", :file => "FILE_LICENSE" }

  s.author             = { "shenjinghao" => "807880748@qq.com" }

  s.source       = { :git => "https://github.com/Shenjinghao/JHDynamicFont.git", :tag => "#{s.version}" }

  s.source_files  = "Classes", "JHDynamicFont/Classes/**/*.{h,m}"
  s.exclude_files = "Classes/Exclude"
  s.requires_arc = true
  s.platform     = :ios

end

具体步骤可以参考相关文章链接

下面主要介绍下集成过程出现的问题及解决方法,以我自己提交的一个项目(JHDynamicFont,通过UIFontDescriptor可以动态修改字体大小,项目地址)为例:

  • NOTE | [OSX] xcodebuild: /Users/shenjinghao/Desktop/Module/MyModule/JHDynamicFont/JHDynamicFont/JHDynamicFont/Classes/JHSliderView.h:9:9: fatal error: 'UIKit/UIKit.h' file not found
  • 出现上面类似的错误是因为在podspec文件中没有加
 s.platform     = :ios
  • ERROR | file patterns: The source_files pattern did not match any file.
  • 出现上面的错误需要把podspec文件中的source_files改成类似下面这种
s.source_files  = "Classes", "JHDynamicFont/Classes/**/*.{h,m}"

-> JHDynamicFont (0.0.1)
- ERROR | [iOS] unknown: Encountered an unknown error ([!] /usr/bin/git clone https://github.com/Shenjinghao/JHDynamicFont.git /var/folders/lc/zl333w0s6t12qjdfl0_brmdh0000gn/T/d20170315-37512-16fmh2q --template= --single-branch --depth 1 --branch 0.0.1
Cloning into '/var/folders/lc/zl333w0s6t12qjdfl0_brmdh0000gn/T/d20170315-37512-16fmh2q'...
warning: Could not find remote branch 0.0.1 to clone.
fatal: Remote branch 0.0.1 not found in upstream origin

  • 出现上面错误的原因是没有为项目打上tag,或者打上tag没有推到远程仓库,在teminal输入下面命令
git tag -m"pod spec" "0.0.1"
git push origin --tags

[!] JHDynamicFont did not pass validation, due to 1 error.
[!] The validator for Swift projects uses Swift 3.0 by default, if you are using a different version of swift you can use a .swift-version file to set the version for your Pod. For example to use Swift 2.3, run:
echo "2.3" > .swift-version.
You can use the --no-clean option to inspect any issue.

  • 出现上面问题在终端输入
echo 3.0 > .swift-version

成功提示

JHDynamicFont passed validation.

  • 出现上面提示说明podspec已经验证成功,可以提交CocoaPods trunk了
--------------------------------------------------------------------------------
 🎉  Congrats

 🚀  JHDynamicFont (0.0.1) successfully published
 📅  February 10th, 04:05
 🌎  https://cocoapods.org/pods/JHDynamicFont
 👍  Tell your friends!
  • 出现上面提示说明提交CocoaPods trunk成功。

刚提交后项目用pod search命令会搜不到,因为本地的索引没有更新,使用下面命令删除索引文件

rm ~/Library/Caches/CocoaPods/search_index.json
  • 最后pod search 命令搜到自己的项目,大功告成

-> JHDynamicFont (0.0.1)
通过为UIFontDescriptor添加category方法实现动态改变指定控件(如UILabel UIButtonLabel等)的字体大小。
pod 'JHDynamicFont', '~> 0.0.1'

2017年03月22日17:46:44更新

Paste_Image.png
  • 出现上面的错误提示可以更新cocoapods,命令如下
sudo gem install cocoapods 
//或者
sudo gem install cocoapods --pre
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容