从零开始制作自己的podspec



前言:CocoaPods相关资料

Commands:

    + repo       Manage spec-repositories

    + search     Searches for pods

    + setup      Setup the CocoaPods environment

    + spec       Manage pod specs

    + trunk      Interact with the CocoaPods API (e.g. publishing new specs)

    + try        Try a Pod!

    + update     Update outdated project dependencies and create new

  •                         

  •     + cache      Manipulate the CocoaPods cache

  •     + init       Generate a Podfile for the current directory.

  •     + install    Install project dependencies to Podfile.lock versions

  •     + ipc        Inter-process communication

  •     + lib        Develop pods

  •     + list       List pods

  •     + outdated   Show outdated project dependencies

  •     + plugins    Show available CocoaPods plugins

  •                  Podfile.lock  

  • Options:

  •         

  •     --silent     Show nothing

  •     --version    Show the version of the tool

  •     --verbose    Show more debugging information

  •     --no-ansi    Show output without ANSI codes

  •     --help       Show help banner of specified command

 

创建CocoaPods核心步骤:

 

    • 上传资源到github

    • 创建、编辑pos spec文件

    • 验证pod spec并提交到Specs

一、上传资源到github

 

    $ git tag -a 1.1.1 -m ’Tag release 1.1.1‘

    $ git push --tags

      添加成功

    Counting objects: 1, done.

    Writing objects: 100% (1/1), 163 bytes | 0 bytes/s, done.

    Total 1 (delta 0), reused 0 (delta 0)

    To https://github.com/c6357/YUKit.git

     * [new tag]         1.1.1 -> 1.1.1

 

 

二、创建编辑pos spec文件

    • 这里以YUKit为例

    • 官方推荐资源目录模板如下

    •  

      $ tree MyLib -L 2

       MyLib
       ├── .travis.yml
       ├── _Pods.xcproject
       ├── Example
       │   ├── MyLib
       │   ├── MyLib.xcodeproj
       │   ├── MyLib.xcworkspace
       │   ├── Podfile
       │   ├── Podfile.lock
       │   ├── Pods
       │   └── Tests
       ├── LICENSE
       ├── MyLib.podspec
       ├── Pod
       │   ├── Assets
       │   └── Classes
       │     └── RemoveMe.[swift/m]
       └── README.md

    • push后添加 tag ( 这里的tag 后面pod spec 文件 version 会用到)     

  •    pod spec create

 $pod spec create [NAME|https://github.com/USER/REPO]
 e.g.  $ pod spec create YUKit https://github.com/c6357/YUKit

            本地会生成一个YUKit.podspec文件

  •   2.编辑 pod spec文件

        YUKit.podspec

        14153338_M37U.png

如何编写请参考官方文档Specification 或者参考网上优秀pod spec 文件

 

三、验证pod spec并提交到Specs

  • 本地验证

    • $ cd ~/.cocoapods/repos/REPO_NAME
    • $ pod lib lint (验证)
    • $ pod lib lint --verbose(验证--并显示详细信息)
    • $ pod lib lint --allow-warning(验证--忽略警告)
    • YUKit passed validation.

  • 注册trunk

    • $ pod trunk register orta@cocoapods.org 'Orta Therox' --description='macbook air'
    • $ pod trunk add-owner YUkit kyle@cocoapods.org(还可以添加其他小伙伴)
    • $ pod trunk me //查看自己的注册信息

                

 - Name:     Orta Therox

  - Email:    orta@cocoapods.org

  - Since:    January 6th, 21:41

  - Pods:

    - YUKit

  - Sessions:

    - January 6th, 21:41 -         Unverified. IP: XXXXX

    - January 6th, 21:42 -    May 13th, 21:42. IP: XXXXX

    - January 6th, 21:44 - August 20th, 00:56. IP: XXXXX

    - January 7th, 08:35 -    May 14th, 09:20. IP: XXXXX

Updating spec repo `master`

Validating podspec

 

Updating spec repo `master`

 

CocoaPods 1.0.0.beta.6 is available.

 

  • 提交到远端(有警告要选最后一个)

    • $ pod trunk push YUKit.podspe
    • $ pod trunk push YUKit.podspe --verbose
    • $ pod trunk push YUKit.podspe --allow-warning

 

四、使用

 

pod'YUKit', '~> 1.1.6'

$pod search yukit

 

   YUKit for iOS.(objective-c 、c++)

   pod 'YUKit', '~> 1.1.6'

   - Homepage: https://github.com/c6357/YUKit

   - Source:   https://github.com/c6357/YUKit.git

   - Versions: 1.1.6, 1.0.4, 1.0.0, 0.0.9 [master repo]

   - Subspecs:

     - YUKit/header (1.1.6)

     - YUKit/foundation (1.1.6)

     - YUKit/foundation/lib (1.1.6)

     - YUKit/foundation/category (1.1.6)

     - YUKit/uikit (1.1.6)

     - YUKit/uikit/lib (1.1.6)

     - YUKit/uikit/category (1.1.6)

     - YUKit/services (1.1.6)

     - YUKit/services/NSJson (1.1.6)

     - YUKit/services/Reachability (1.1.6)

     - YUKit/base (1.1.6)

     - YUKit/base/NavigationController (1.1.6)

     - YUKit/base/ViewController (1.1.6)

     - YUKit/base/TableView (1.1.6)

     - YUKit/base/View (1.1.6)     - YUKit/base/ViewModel (1.1.6)

YUKit代码地址

使用示例YUKitExample

 

创建私有的请查阅官方文档

 

转载于:https://my.oschina.net/u/868062/blog/659470

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PodspecCocoaPods使用的一种文件格式,用于描述一个库的元数据信息。在Flutter插件开发中,我们需要使用Podspec文件来描述iOS平台上的插件信息,以便其他开发者在使用我们的插件时能够正确地集成到他们的项目中。 下面是一些关于Podspec语法的整理: 1. Podspec文件的命名应该以插件的名称为准,并以`.podspec`作为文件扩展名,如`flutter_my_plugin.podspec`。 2. Podspec文件应该包含以下信息: - 插件的名称和版本号 - 插件的描述 - 作者信息 - 插件的许可证 - 插件依赖的库和框架 - 插件的源代码文件和资源文件 3. Podspec文件的基本结构如下: ``` Pod::Spec.new do |s| s.name = '插件名称' s.version = '插件版本号' s.summary = '插件描述' s.homepage = '插件主页' s.license = '插件许可证' s.author = { '作者名称' => '作者邮箱' } s.source = { :git => '插件源代码仓库地址', :tag => '插件版本号' } s.dependency '依赖库名称', '依赖库版本号' # 插件依赖的库和框架 s.source_files = '插件源代码文件路径' # 插件的源代码文件 s.resource_bundles = { '插件资源文件名称' => ['插件资源文件路径'] } # 插件的资源文件 end ``` 4. 在描述依赖库时,可以使用以下语法: - `s.dependency '库名称'`:插件依赖的库名称。 - `s.dependency '库名称', '~> 版本号'`:插件依赖的库名称和版本号,其中`~>`表示兼容某个版本号及以上的库。 - `s.dependency '库名称', '>= 版本号'`:插件依赖的库名称和版本号,其中`>=`表示需要某个版本号及以上的库。 5. 在描述源代码文件和资源文件时,可以使用以下语法: - `s.source_files = '路径/**/*.{h,m,swift}'`:插件的源代码文件路径,可以使用通配符`*`和`**`。 - `s.resource_bundles = { 'Bundle名称' => ['路径/**/*'] }`:插件的资源文件,可以使用通配符`*`和`**`。 以上就是关于Podspec语法的整理,希望能对Flutter插件开发有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值