美文网首页
【Swift】制作公有库

【Swift】制作公有库

作者: BeethOven | 来源:发表于2020-08-10 15:33 被阅读0次
image

1.新建github仓库

image

注意点

  • Repository Name 仓库名
  • Add a license 开源许可证 一般选MIT

2.本地新建.podsepc文件

新建一个文件夹,打开终端,执行命令

$ wujiandeMacBook-Pro:RLPublicLib wujian$ pod lib create RLPublicLib

回答以下问题

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

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

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

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

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

Running pod install on your new library.

完成后会自动生成带有Example的工程,工程目录如图所示

image

2.编辑.podspec文件

#
# Be sure to run `pod lib lint RLPublicLib.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             = 'RLPublicLib'
  s.version          = '0.1.0'
  s.summary          = '测试公有库的创建'

# 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://www.jianshu.com/p/710e5c598d76'
  # s.screenshots     = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
  s.license          = { :type => 'MIT', :file => 'LICENSE' }
  s.author           = { '1056709274@qq.com' => 'wujianren@chandashi.com' }
  s.source           = { :git => 'https://github.com/Conan-R/PublicLibTest.git', :tag => s.version.to_s }
  # s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'

  s.ios.deployment_target = '9.3'

  s.source_files = 'RLPublicLib/Classes/**/*'
  
  # s.resource_bundles = {
  #   'RLPublicLib' => ['RLPublicLib/Assets/*.png']
  # }
  s.frameworks = 'UIKit'
  s.dependency 'SnapKit'
  s.swift_version = '4.2'
end

官方文档

注意

  • s.summary 公有库简介 一定要修改

  • wift的话记得加版本号 s.swift_version = '4.2'

  • 依赖的第三方库可以使用s.dependency 'SnapKit'

  • s.source 的地址要修改成github仓库地址

编辑完可以使用命令进行验证 pod lib lint [xxx.podspec] [--allow-warnings] [--verbose]

$ wujiandeMacBook-Pro:RLPublicLib wujian$ pod lib lint

 -> RLPublicLib (0.1.0)
    - NOTE  | xcodebuild:  note: Using new build system
    - NOTE  | [iOS] xcodebuild:  note: Planning build
    - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    - NOTE  | [iOS] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')

RLPublicLib passed validation.
wujiandeMacBook-Pro:RLPublicLib wujian$ 

3.加入项目文件

image
$ pod update --verbose --no-repo-update

4.把文件push到github的仓库上,并打tag包

$ git remote add origin https://github.com/Conan-R/PublicLibTest.git
$ git push -u origin master
$ git tag -a 0.1.0 -m '创建 pod 库'
$ git push origin --tags

5.注册Trunk

先用命令 pod trunk me 判断是否已经注册

wujiandeMacBook-Pro:RLPublicLib wujian$ pod trunk me
[!] Authentication token is invalid or unverified. Either verify it with the email that was sent or register a new session.

我这里是还没注册, 执行命令进行注册pod trunk register EMAIL [YOUR_NAME]

pod trunk register 1056709274@qq.com "RL_Conan"

到自己邮箱里打开邮件打开链接看见下面这个画面就OK了, 我这里是在垃圾邮件里找到的

image

再次执行命令pod trunk me

$ wujiandeMacBook-Pro:RLPublicLib wujian$ pod trunk register 1056709274@qq.com "RL_Conan"
[!] Please verify the session by clicking the link in the verification email that has been sent to 1056709274@qq.com
wujiandeMacBook-Pro:RLPublicLib wujian$ pod trunk me
  - Name:     Conan-R
  - Email:    1056709274@qq.com
  - Since:    March 10th, 07:26
  - Pods:
    - RLBase
    - RLNewBase
  - Sessions:
    - March 10th, 07:26 -    July 24th, 22:58. IP: 106.122.182.15
    - August 3rd, 21:31 - December 9th, 21:34. IP: 117.28.112.79 

6.发布公有库

执行命令: pod trunk push [NAME].podspec

$ pod trunk push RLPublicLib.podspec
image

最后可以通过命令查找库: pod search RLPublicLib

相关文章

  • 【Swift】制作公有库

    1.新建github仓库 注意点 Repository Name 仓库名 Add a license 开源许可证 ...

  • 制作Pod库

    目录 一、公有Pod库制作 二、私有Pod库制作 三、subspec子库的制作 四、遇到的坑 一、公有Pod库制作...

  • cocoapods制作公有库

    1、新建仓库: 登录github,新建一个仓库(Repository): 2、clone仓库到本地: 1、 cop...

  • cocoaPods制作公有库

    一、登录github,创建新的远程库(存放代码) 二、创建本地代码库 终端输入pod lib create 库名称...

  • github 公有库制作

    https://www.jianshu.com/p/de72a92db4e7

  • cocoapods制作公有库

    1、先在终端搜索一下看看名字是不是冲突 如果没有冲突,就在github新建项目,并 git clone 到本地。2...

  • iOS的Framework静态库

    静态库VS动态库 静态库不需要签名,动态库需要签名。 制作混编静态库 库内部Swift调用OC的头文件Swift调...

  • CocoaPods进阶:制作公有库

    一、 前言 在CocoaPods进阶:详解私有库制作这篇博客中,讲解记录了cocoapods使用pod lib c...

  • 检测私有库报错 [iOS] unknown: Encounte

    问题描述项目模块化时,我们制作的私有库免不了依赖其他私有库和CocoaPods的公有库。在产品更新迭代制作新版本的...

  • swift ios 静态库的实现

    1.swift不支持.a的静态库,因此只能制作.framework的静态库 2.静态库的使用 3.纯swift静态...

网友评论

      本文标题:【Swift】制作公有库

      本文链接:https://www.haomeiwen.com/subject/stjjdktx.html