美文网首页Flutter学习
fastlane自动化打包并提交AppStore

fastlane自动化打包并提交AppStore

作者: 移动端_小刚哥 | 来源:发表于2018-08-22 18:40 被阅读157次

    fastlane是一个通过简单命令来完成诸如截图、获取证书、编译、导出安装包、提交iTunesConnect等一系列操作的工具,它同时支持iOS和Android。
    你能够通过简单的方式配置流程进行的顺序,并通过非常简单的命令执行其中的一个流程。当然它的简单并不代表功能也简陋,有开源社区的支持,更新迅速且有很多功能能够满足你的需求。

    fastlane

    一、环境配置

    fastlane使用的是ruby环境且对ruby有版本要求(官网要求是ruby2.0以上),所以如果需要的话更新一波ruby,然后通过homebrew安装fastlane(或者通过gem安装,看心情😄)

    检查是否安装ruby并查看ruby版本号
    ruby -v
    
    //我的已经安装ruby环境
    ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
    
    如果没有ruby环境或者ruby环境低于2.0版本
    brew install ruby
    
    然后检查 Xcode 命令行工具
    xcode-select --install
    

    如果报错误:command line tools are already installed, use "Software Update" to install updates.代表已经安装,否则会开始安装。

    安装fastlane
    sudo gem install fastlane
    

    二、使用fastlane

    新建iOS项目并cd到项目中,然后执行:

    //cd到工程中,然后执行
    fastlane init
    

    [18:05:57]: What would you like to use fastlane for?

    1. 📸 Automate screenshots
    2. 👩‍✈️ Automate beta distribution to TestFlight
    3. 🚀 Automate App Store distribution
    4. 🛠 Manual setup - manually setup your project to automate your tasks

    1 自动截图
    2 打包测试
    3 打包上传到appStore
    4 先什么都不干,后面手动配置

    我们要上传AppStore选择3,然后会让输入开发者账号和密码,还可能弹出来一个6位验证码,记住这个验证码并输入回车

    需要用户名和密码:

    [18:07:34]: Please enter your Apple ID developer credentials
    [18:07:34]: Apple ID Username:

    因为我们的开发这账号有公司账号和企业账号,而且用的同一个邮箱,所以需要选择一下:

    Multiple teams found on the Developer Portal, please enter the number of the team you want to use:

    1. xxxxx "IvyGate International Education Technology Co. Ltd" (In-House)
    2. xxxxx "IvyGate International Education Technology Co. Ltd" (Company/Organization)

    1是企业账号,内部分发用的299💲哪个
    2是公司账号

    然后一路输入 y 或者回车......
    如果bundle update卡住无响应那么很有可能是因为被墙了,首先在终端检查ruby源

    gem source
    
    //可以看到自己的信息,我的已经替换为gems.ruby-china了
    *** CURRENT SOURCES ***
    
    https://gems.ruby-china.com/
    

    如果不是https://gems.ruby-china.com/那么替换一下

    gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
    

    然后打开工程中的Gemfile文件

    source "https://rubygems.org"
    替换为
    source "https://gems-china.org"//taobao的已经停止维护了,国内就用这个
    

    然后删除fastlane文件夹,打开终端,cd到工程中,再次执行

    fastlane init
    

    执行完毕之后分别进入developer和itunesconnect去看一下appid和app都被新建好了

    三、打包提交到AppStore

    终端执行

    fastlane release
    

    有可能报错

    [14:12:17]: Unsupported directory name(s) for screenshots/metadata in './fastlane/screenshots': screenshots
    Valid directory names are: ["da", "de-DE", "el", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi", "fr-CA", "fr-FR", "id", "it", "ja", "ko", "ms", "nl-NL", "no", "pt-BR", "pt-PT", "ru", "sv", "th", "tr", "vi", "zh-Hans", "zh-Hant", "appleTV", "iMessage", "default"]

    Enable 'ignore_language_directory_validation' to prevent this validation from happening

    +------+---------------------+-------------+
    | fastlane summary |
    +------+---------------------+-------------+
    | Step | Action | Time (in s) |
    +------+---------------------+-------------+
    | 1 | default_platform | 0 |
    | 2 | build_app | 52 |
    | 💥 | upload_to_app_store | 84 |
    +------+---------------------+-------------+

    [14:12:17]: fastlane finished with errors

    [!] Unsupported directory name(s) for screenshots/metadata in './fastlane/screenshots': screenshots
    Valid directory names are: ["da", "de-DE", "el", "en-AU", "en-CA", "en-GB", "en-US", "es-ES", "es-MX", "fi", "fr-CA", "fr-FR", "id", "it", "ja", "ko", "ms", "nl-NL", "no", "pt-BR", "pt-PT", "ru", "sv", "th", "tr", "vi", "zh-Hans", "zh-Hant", "appleTV", "iMessage", "default"]

    Enable 'ignore_language_directory_validation' to prevent this validation from happening

    看意思是需要忽略语言文件检查,打开工程->fastlane文件夹->Fastfile

    upload_to_app_store
    改为
    upload_to_app_store(
        ignore_language_directory_validation: true
        )
    

    如图:


    忽略检查

    再次执行

    fastlane release
    

    中间可能打开浏览器然后蹦出来一个网页告诉你No Screenshots Found没有截图啥的,先不用管以后再完善,点击y过去

    进入itunesconnect查看app

    提交成功了

    提交成功了!!!

    参考地址:

    文档地址:https://docs.fastlane.tools/actions/appstore/

    http://devhy.com/2018/01/23/26-fastlane-usage/
    https://gems.ruby-china.com
    https://www.jianshu.com/p/192c09cc8e27

    相关文章

      网友评论

        本文标题:fastlane自动化打包并提交AppStore

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