美文网首页
组件20:组件化-自动化

组件20:组件化-自动化

作者: Lovell_ | 来源:发表于2017-07-12 16:56 被阅读39次

    什么是自动化?
    通过简单的一条命令, 去自动执行一组固定操作

    自动化的使用场景?
    测试
    打包上传审核
    分发

    自动化方案?
    fastlane(快速航道):Fastlane是一个ruby脚本集合

    关于Fastlane的概念

    • lane:航道
    • Action机制:
      1. Action是Fastlane自动化流程中的最小执行单元,体现在Fastfile脚本中的一个个命令

      2. 比如:cocoapods, git_add等等,而这些命令背后都对应一个用Ruby编写的脚本。

      3. 目前所有的Action:

      4. 常用action:

      • produce 创建可用于 iTunes Connect 和 Apple Developer Portal 的 iOS app。
      • cert 自动创建和维护 iOS 代码签名证书。
      • sigh 创建、更新、下载和修复 provisioning profiles。
      • snapshot 自动将 App 屏幕截图本地化到每种设备上。
      • frameit 将屏幕截图适配到适当的设备屏幕大小。
      • gym 创建和打包 iOS app。
      • deliver 上传屏幕截图、元数据和 App 到 App 商店。
      • PEM 自动创建和更新 Push 通知的 profile。

    fastlane安装(有近200M)
    sudo gem install -n /usr/local/bin fastlane,如果要求Ruby版本最新:brew update

    fastlane使用
    1.进入根目录
    2.fastlane init:如果不需要上传等操作,
    3.在Fastfile文件中, 描述不同的"航道"
    4.在项目根目录下, 执行某个"航道"

    实践操作

    1. 选一个组件来操作LFRemotePlayer
    2. 创建本地库,pod lib create LFRemotePlayer,拖入代码
    3. 创建纯净远程库
    4. 修改LFRemotePlayer的描述文件
    5. 添加远程关联,cd LFRemotePlayer,git remote add origin https://git.oschina.net/lovell123/LFRemotePlayer.git
    6. 以上只需做一次,以下每次都要做,用fastlane
    7. fastlane init : (LFRemotePlayer文件夹内多出fastlane文件夹,LFRemotePlayer文件夹所在层次多出build文件夹),然后要填入付费的苹果开发者账号和密码,会在账号对应的Dev Center和iTunes connect创建一个新的APP,最后会在本地生成截屏信息、各种文件夹,这是后期做打包、测试、分发时候要用到的东西。但目前我们要做的是维护一个本地的私有库,还不需要那些东西,最重要的是我没有付费的开发者账号!所以fastlane init 无法最终完成,control + z,终止。删掉build文件夹,删掉fastlane文件夹里面的Appfile。


      填入付费账号.png
      fastlane init生成的东西.png
      fastlane操作的根目录.png
    8. 进入fastlane文件夹,touch Fastfile,Fastfile是类似Podfile的一种文件。Fastfile是用于描述航道的。
    9. 编写航道:Fastfile里面的路径都是相对根目录来写,比如podfile的路径,是从Fastfile位置到根目录再到podfile的位置:
    # 1. pod install
    cocoapods(
    clean: true,
    podfile: "./Example/Podfile"
    )
    
    1. cd 回到根目录,fastlane lanes,检验是否有语法错误,如下图表示没错,但不代表逻辑没错。
      Snip20170712_129.png
    2. 使用fastlane:fastlane ManagerLib tag:0.1.0 target:LFRemotePlayer
    3. 检索pod search LFRemotePlayer,报错如下。解决:1、pod cache clean --all清缓存,2、删索引缓存search_index.json(位置:/Users/fengluo/Library/Caches/CocoaPods/search_index.json
      ),3、再搜索,即可。
      Snip20170712_131.png
    4. 宿主工程使用。
      宿主podfile中引入source,pod 'repo name',pod install,随便导入库某一个头文件,编译成功即可。
    Fastfile解释.png Snip20170712_138.png

    遇到的问题

    1. 如果在spec文件夹里面用 pod repo add <repo name>,会添加失败,退到repos文件夹。
    2. 注意忽略文件加上.DS_Store
    3. spec描述文件验证、推送加上allow_warnings
    4. 刚提交完spec描述文件,pod search 搜索不到,这时候清缓存pod cache clean --all,删搜索缓存文件search_index.json,再次搜索即可成功。
    5. fastlane init需要付费的账号才能成功,有好些功能:打包、测试、分发等,若是没有,则control+z停止,在fastlane文件夹中touch Fastfile,我们只需要维护一个本地私有库。

    相关文章

      网友评论

          本文标题:组件20:组件化-自动化

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