美文网首页女程序猿程序员
fastlane 自动化打包上传fir

fastlane 自动化打包上传fir

作者: meryin | 来源:发表于2018-06-11 10:33 被阅读5次

    fastlane文档:https://docs.fastlane.tools/

    一 安装

    1. 确保Xcode安装了最新版本的命令行工具
     xcode-select --install
    
    1. 安装需要ruby2.1以上,升级ruby
    ruby -v
    rvm install 2.4.0
    

    升级过程中可能会出现局部升级ruby,出现多个ruby版本

    • 删除多余ruby:
    which ruby
    /Users/mac/.rvm/rubies/ruby-2.0.0-p648/bin/ruby
    

    然后在/Users/mac/.rvm/rubies文件夹中删除多余ruby

    • 切换版本

    查看ruby版本:

    ➜  ~ rvm list
    
    rvm rubies
    
     * ruby-2.4.0 [ missing bin/ruby ]
       ruby-2.4.1 [ x86_64 ]
    
    # => - current
    # =* - current && default
    #  * - default
    

    查看当前ruby版本:rvm current
    切换版本:rvm --default use 2.4.1
    此时再 which ruby可以看见切换成功
    /Users/mac/.rvm/rubies/ruby-2.4.1/bin/ruby

    1. 安装fastlane
    sudo gem install fastlane --verbose
    

    二 安装fir插件

    1. cd你的项目根目录
    2. 初始化fastlane
      fastlane init
    • 出现以下选项:
    [18:07:18]: 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
    

    我选择3

    • 输入developer账号密码:
    [18:09:05]: Please enter your Apple ID developer credentials
    [18:09:05]: Apple ID Username:
    
    • Would you like fastlane to manage your app's metadata? (y/n)
      选y
    1. 安装fir插件
      fastlane add_plugin firimfastlane install_plugins
      安装成功
    +-----------------------+---------+--------+
    |               Used plugins               |
    +-----------------------+---------+--------+
    | Plugin                | Version | Action |
    +-----------------------+---------+--------+
    | fastlane-plugin-firim | 0.2.0   | firim  |
    +-----------------------+---------+--------+
    
    Installing plugin dependencies...
    Successfully installed plugins
    

    安装成功过后目录如下:


    • 如果你的项目使用了cocoapods, 需要在Gemfile中添加一行:
      gem 'cocoapods'
    • 自动上传到fir还需:
      gem install fir-cli

    三 编写自动打包上传的代码

    Fastfile中添加:

    
    default_platform(:ios)
    
    platform :ios do
      desc "Push a new release build to the App Store"
      lane :release do
        build_app(export_method: "app-store",workspace: "CheLingWang.xcworkspace", scheme: "CheLingWang",output_directory:"./build",export_options: {
          provisioningProfiles: { 
            "com.example.bundleid" => "Provisioning Profile Name",    
          }
        })
        deliver(force: true)
        slack(message: "Successfully uploaded a new App Store build")
      end
      desc "Runs all the tests"
      lane :test do
        scan
      end
      desc "ipa打包"
      lane :createIpa do
        # sigh(adhoc:true)  #如果要使用ad-hoc打包, 则需打开此项配置
        gym(scheme: "CheLingWang",workspace: "CheLingWang.xcworkspace", configuration: "Debug",clean: true, export_method:"development")
        enable_automatic_code_signing(path: "CheLingWang.xcodeproj")
    
        end
      desc "Deploy a test version to the fir.im" 
      lane :firUp do
        createIpa 
        firim(firim_api_token: "520eba03dfc3eea40ef0fbad69ca1113") 
      end
    end
    
    

    进行打包命令:
    fastlane createIpa
    上传fir:fastlane firUp
    上传App Store:fastlane release

    • scheme: 工程的scheme
    • firim_api_token:fir的API_token
    • configuration: 编译方式为Debug 默认为Release
    • export_method: 打包导出方式, 包括 app-store, ad-hoc, package, enterprise, development, developer-id
    • scan 自动化测试工具对 UnitTest的封装
    • gym 编译打包生成 ipa 文件
    • deliver 上传应用的二进制代码,应用截屏和元数据到 App Store
    • snapshot 可以自动化iOS应用在每个设备上的本地化截屏过程
    • 所有actions

    相关文章

      网友评论

        本文标题:fastlane 自动化打包上传fir

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