美文网首页iOS杂技
CocoaPod 常用命令

CocoaPod 常用命令

作者: 蒂埃里 | 来源:发表于2017-07-28 13:45 被阅读0次

    简介

    CocoaPods 是 iOS 非常常用的类库管理工具

    作为 iOS 程序员,掌握 CocoaPods 的常用终端命令,是必不可少的基本技能

    集成框架命令

    # 创建默认的 Podfile

    $ pod init

    # 第一次使用安装框架

    $ pod install

    # 安装框架,不更新本地索引,速度快,但是不会升级本地代码库

    $ pod install --no-repo-update

    # 今后升级、添加、删除框架

    $ pod update

    # 更新框架,不更新本地索引,速度快

    # 可以安装新框架或者删除不用的框架,但是不会升级项目已经安装的框架

    $ pod update --no-repo-update

    # 查看哪些框架有更新版本,如果习惯使用 `--no-repo-update` 参数,这个命令就显得格外重要了 

    $ pod outdated

    # 搜索框架

    # - 空格 下一页

    # - q 退出

    # - / 搜索

    $ pod search AFNetworking

    # 只搜索复合名字的框架,这个对于搜索结果非常多时,尤其有用

    $ pod search AFNetworking --simple

    # 帮助

    $ pod --help

    pod 安装和升级

    # 安装测试版

    $ sudo gem install cocoapods --pre

    # 删除老版本的程序包

    $ sudo gem cleanup

    # 升级所有程序包

    $ sudo gem update

    # 升级 gem

    $ sudo gem update --system

    Podfile 格式说明

    # 最低支持的 iOS 版本

    platform :ios,'8.0'

    # Swift 项目需要使用 `frameworks`

    # OC 和 Swift 混编项目也需要使用 `frameworks`

    # 如果使用 `framework`,OC 文件在导入头文件时需要使用 `@import xxx;` 格式

    use_frameworks!

    # DemoProject 安装的框架列表,cocoapod 1.0 版本以上一定要有

     targettarget'DemoProject'do

    # ~> 后面的数字是 3.0.4 版本,如果省略,则安装或升级最新版本

    pod'AFNetworking','~> 3.0.4'

    end

    # DemoProjectTests 安装的框架列表

    target'DemoProjectTests'do

    end

    # DemoProjectUITests 安装的框架列表

    target'DemoProjectUITests'do

    end

    自制框架

    // 注册&激活

    $ pod trunk register ios@itcast.cn "itheima"

    // 查询 pod 注册信息

    $  pod trunk me

    // 生成 spec 文件

    $  pod spec create https://github.com/liufan321/SwiftQRCode.git

    // 打标签

    $ git tag -a 1.0.0 -m "Tag release 1.0.0"

    // 推送标签

    $ git push --tags

    // 编辑 spec 文件

    $  vim SwiftQRCode.podspec

    // 验证 spec 文件

    $  pod spec lint SwiftQRCode.podspec --verbose

    关于podspec的具体格式,可以参照其他第三方框架的编写格式

    相关文章

      网友评论

        本文标题:CocoaPod 常用命令

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