当前位置:   article > 正文

使用码云(git.oschina)做私有的CocoaPods仓库_码云私有部署

码云私有部署

CocoaChina

简书

首先感谢两位的文章对我的帮助!

想弄自己的CocoaPods仓库很久了,因为我们公司产品有两个端,很多代码都是相似的,有时直接是复制粘贴过来是很不方便的,经常改动又没想到封装成静态库文件,之前也尝试过很多次,总是失败,所以这次我也会把自己之前踩的坑分享出来.

1.在码云上注册自己的帐号


2.首先创建一个项目放置spec(之前创建就是没明白这个关系,这个详细后面用到讲)


最好选择初始化项目,后面会方便很多.

然后得到地址 https://git.oschina.net/sch1111878/private-specs.git


3.再新建一个项目  (github上的repository,)这个是用来存放我们用到的类文件的

和第二步比较相似不贴图了,注意这个名称是不能重复的,所以点击创建前在 pod search xxx 来搜索下是比较靠谱的,我用的是 SCHPodsTest


这样就是别人没有注册的.

我们得到https://git.oschina.net/sch1111878/schpodstest.git

4.把第三步创建的项目拷贝下来,我使用的SourceTree来管理Git,比较简单,

从url克隆就可以了,然后打开本地目录,

然后提交,记得一个要打tag 值,对应的下面的 s.version

这里我们建一个自己的类,目录如下


然后键入

pod spec create SCHPodsTest
然后就会多出一个.podspec 文件,

然后编辑他,我使用的是sublime

  1. #
  2. # Be sure to run `pod spec lint SCHPodsTest.podspec' to ensure this is a
  3. # valid spec and to remove all comments including this before submitting the spec.
  4. #
  5. # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
  6. # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
  7. #
  8. Pod::Spec.new do |s|
  9. # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  10. #
  11. # These will help people to find your library, and whilst it
  12. # can feel like a chore to fill in it's definitely to your advantage. The
  13. # summary should be tweet-length, and the description more in depth.
  14. #
  15. s.name = "SCHPodsTest"
  16. # 这个地方一定要注意了,你的git提交要打上对应的tag值才能拉取
  17. s.version = "0.0.1"
  18. s.summary = "A short description of SCHPodsTest."
  19. # This description is used to generate tags and improve search results.
  20. # * Think: What does it do? Why did you write it? What is the focus?
  21. # * Try to keep it short, snappy and to the point.
  22. # * Write the description between the DESC delimiters below.
  23. # * Finally, don't worry about the indent, CocoaPods strips it!
  24. s.description = <<-DESC
  25. 演示Demo
  26. DESC
  27. s.homepage = "http://EXAMPLE/SCHPodsTest"
  28. # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
  29. # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  30. #
  31. # Licensing your code is important. See http://choosealicense.com for more info.
  32. # CocoaPods will detect a license file if there is a named LICENSE*
  33. # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
  34. #
  35. s.license = "MIT"
  36. # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
  37. # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  38. #
  39. # Specify the authors of the library, with email addresses. Email addresses
  40. # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
  41. # accepts just a name if you'd rather not provide an email address.
  42. #
  43. # Specify a social_media_url where others can refer to, for example a twitter
  44. # profile URL.
  45. #
  46. s.author = { "blank" => "sch1111878@126.com" }
  47. # Or just: s.author = "blank"
  48. # s.authors = { "blank" => "sch1111878@126.com" }
  49. # s.social_media_url = "http://twitter.com/blank"
  50. # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  51. #
  52. # If this Pod runs only on iOS or OS X, then specify the platform and
  53. # the deployment target. You can optionally include the target after the platform.
  54. #
  55. s.platform = :ios
  56. s.platform = :ios, "5.0"
  57. # When using multiple platforms
  58. # s.ios.deployment_target = "5.0"
  59. # s.osx.deployment_target = "10.7"
  60. # s.watchos.deployment_target = "2.0"
  61. # s.tvos.deployment_target = "9.0"
  62. # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  63. #
  64. # Specify the location from where the source should be retrieved.
  65. # Supports git, hg, bzr, svn and HTTP.
  66. #
  67. s.source = { :git => "https://git.oschina.net/sch1111878/schpodstest.git", :tag => "#{s.version}" }
  68. # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  69. #
  70. # CocoaPods is smart about how it includes source code. For source files
  71. # giving a folder will include any swift, h, m, mm, c & cpp files.
  72. # For header files it will include any header in the folder.
  73. # Not including the public_header_files will make all headers public.
  74. #
  75. s.source_files = "Classes", "Classes/**/*.{h,m}"
  76. s.exclude_files = "Classes/Exclude"
  77. # s.public_header_files = "Classes/**/*.h"
  78. # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  79. #
  80. # A list of resources included with the Pod. These are copied into the
  81. # target bundle with a build phase script. Anything else will be cleaned.
  82. # You can preserve files from being cleaned, please don't preserve
  83. # non-essential files like tests, examples and documentation.
  84. #
  85. # s.resource = "icon.png"
  86. # s.resources = "Resources/*.png"
  87. # s.preserve_paths = "FilesToSave", "MoreFilesToSave"
  88. # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  89. #
  90. # Link your library with frameworks, or libraries. Libraries do not include
  91. # the lib prefix of their name.
  92. #
  93. s.framework = "UIKit"
  94. # s.frameworks = "SomeFramework", "AnotherFramework"
  95. # s.library = "iconv"
  96. # s.libraries = "iconv", "xml2"
  97. # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
  98. #
  99. # If your library depends on compiler flags you can set them in the xcconfig hash
  100. # where they will only apply to your library. If you depend on other Podspecs
  101. # you can include multiple dependencies to ensure it works.
  102. s.requires_arc = true
  103. # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
  104. # s.dependency "JSONKit", "~> 1.4"
  105. end

我把全部的都粘贴上了, 这里要注意的几个点是

 * platform

 * source

 * framework

然后就可以执行 pod spec lint 来检查, 如果有Error 看内容修改,这个修改对应就好了,想起以前做这个看到错误就直接卡住了,warn是可以忽略的,假如只有warn,

我这里突然蹦一个Swift版本不对,无视就可以了.

使用pod spec lint --allow-warnings 就可以了,

如果看到提示 passed validating 就是通过了.

然后就用到第一次的那个repo了,

pod repo add uupt https://git.oschina.net/sch1111878/private-specs.git

通过 pod repo list 查看是否成功


然后 pod repo push uupt xxx.podspec --allow-warnings

等提示推送完成,就可以用的,


Podfile中 最顶部加入我们的私有 https://git.oschina.net/sch1111878/private-specs.git

然后 pod 'SCHPodsTest' 

不出以外就能看到成功了.

以后修改文件时提交改tag值就可以了.


如果有其他问题可以私信或评论问我

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/酷酷是懒虫/article/detail/823668
推荐阅读
相关标签
  

闽ICP备14008679号