IOS

SVN创建CocoaPods私有库

2018-11-27  本文已影响32人  啵啵_long_港

一、安装Pod Svn插件

https://github.com/dustywusty/cocoapods-repo-svn

1、gem install cocoapods-repo-svn 会报错:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

使用 sudo gem install cocoapods-repo-svn,输入密码

Password:
Fetching: cocoapods-repo-svn-3.0.0.gem (100%)
Successfully installed cocoapods-repo-svn-3.0.0
Parsing documentation for cocoapods-repo-svn-3.0.0
Installing ri documentation for cocoapods-repo-svn-3.0.0
Done installing documentation for cocoapods-repo-svn after 0 seconds
1 gem installed

2、$ pod repo-svn add my-svn-repo http://svn-repo-url
例如:pod repo-svn add CommonLib http://svn-repo-url
显示错误

svn: E230001: Server SSL certificate verification failed: certificate issued for a different hostname, issuer is not trusted

证书问题
svn ls https://svn地址,输入p,然后根据提示输入用户名和密码

二、创建CocoaPods私有库


image.png

1、cd 到对应的svn目录下
2、pod lib create CommonLib

What platform do you want to use?? [ iOS / macOS ]
 > iOS

What language do you want to use?? [ Swift / ObjC ]
 > ObjC

Would you like to include a demo application with your library? [ Yes / No ]
 > Yes

Which testing frameworks will you use? [ Specta / Kiwi / None ]
 > None

Would you like to do view based testing? [ Yes / No ]
 > Yes

3、修改.podspec文件内容

podspec.png
#
# Be sure to run `pod lib lint CommonLib.podspec' to ensure this is a
# valid spec before submitting.
#
# Any lines starting with a # are optional, but their use is encouraged
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html
#

Pod::Spec.new do |s|
  s.name             = 'CommonLib'
  s.version          = '0.1.0'
  s.summary          = 'CommonLib.'

# This description is used to generate tags and improve search results.
#   * Think: What does it do? Why did you write it? What is the focus?
#   * Try to keep it short, snappy and to the point.
#   * Write the description between the DESC delimiters below.
#   * Finally, don't worry about the indent, CocoaPods strips it!

  s.description      = <<-DESC
TODO: Add long description of the pod here.
                       DESC

  s.homepage         = 'https://github.com/ProBobo'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { 'ProBobo' => 'https://github.com/ProBobo' }
  s.source           = { :svn => '对应的svn地址/CommonLib', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '8.0'

  s.source_files = 'CommonLib/Classes/**/*'
  
  # s.resource_bundles = {
  #   'CommonLib' => ['CommonLib/Assets/*.png']
  # }

  # s.public_header_files = 'Pod/Classes/**/*.h'
  # s.frameworks = 'UIKit', 'MapKit'
  # s.dependency 'AFNetworking', '~> 2.3'
end

s.summary 需要修改成自己的内容
s.homepage 需要修改成可以访问的地址
s.source 修改成对应的svn地址

4、pod lib lint CommonLib.podspec 检查podspec文件是否可用,如果有错误,根据提示修改

三、使用Podfile文件
在Podfile文件中添加CommonLib,修改源地址为svn地址

pod 'CommonLib', :svn =>'svn地址/CommonLib'

执行pod install即可安装Cocoapods私有库

更新指定第三方库

pod update 库名

更新某个第三方,不更新其他本地第三方

pod update 库名  --verbose --no-repo-update

给项目添加新的第三方,不更新本地已经存在的第三方

pod install --verbose --no-repo-update
上一篇下一篇

猜你喜欢

热点阅读