美文网首页
利用fastlane实现iOS自动化打包并且上传到fir

利用fastlane实现iOS自动化打包并且上传到fir

作者: 阿洋12138 | 来源:发表于2019-05-27 11:25 被阅读0次

    1、检查Mac是否已经安装ruby:

    终端或者iTerm执行命令行:ruby -v 
    

    2、检查本地是否安装Xcode命令行工具:

    终端或者iTerm执行命令行:xcode-select --install
    

    3、安装fastlane:

    终端或者iTerm执行命令行:
    sudo gem install fastlane
    如果有安装Homebrew:
    brew install fastlane
    

    4、切换到工程所在目录进行fastlane初始化:

    终端或者ITerm执行命令行:fastlane init
    
    会出现4个选项
    第1个选项的意思是:自动截屏。 这个功能能帮我们自动截取APP中的截图;
    第2个选项的意思是:自动发布beta版本用于TestFlight;
    第3个选项的意思是:自动发布到AppStore;
    第4个选项的意思是:手动设置。
    

    如果bundle update卡住无响应,https://rubygems.org/这个网址因为域名的原因停止使用了

    1.首先在终端检查ruby源 `gem source -l` 检查`https://gems.ruby-china.com/`
    如果不是请替换下
    `gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.com/`
    
    2.打开工程中的Gemfile文件
    source "https://rubygems.org"
    替换为
    source "https://gems-china.com"
    如果是用cocopod管理的项目 请加上
    gem "cocoapods"
    
    
    3.删除fastlane文件夹,打开终端,cd到工程中,再次执行fastlane init
    

    5、初始化完成之后,回到工程目录,会发现多了Gemfile文件、Gemfile.lock文件和fastlane文件夹,其中fastlane文件夹中包含Appfile和Fastfile两个文件。
    在Appfile文件里做好配置:主要就是bundle id

    以下是直接针对不同的lane设置bundleId
    
    for_lane :xxxTest do
    app_identifier "com.xxx.xxx.test"
    end
    
    
    for_lane :xxx do
    app_identifier "com.xxx.xxx"
    end
    

    在Fastfile文件里做如下配置:可以配置多个lane

    # Uncomment the line if you want fastlane to automatically update itself
    # update_fastlane
    # 好几种方式有app-store,ad-hoc,development,enterprise
    
    default_platform(:ios)
    
    platform :ios do
    
        desc "fir.im日常更新"
    
        lane :xxxTest do
          gym(scheme: "xxxTest",
              workspace: "xxx.xcworkspace",
              include_bitcode: true,
              configuration: "Release",
              export_method: "development",
              output_directory: "/Users/nsyworker/Desktop",
              output_name: "xxx测试版",
              silent: false,
              include_symbols: true)
              firim(firim_api_token: "xxxxxxxxx")
        end
    
    
        lane :xxx do
            gym(scheme: "xxx",
                workspace: "xxx.xcworkspace",
                include_bitcode: true,
                configuration: "Release",
                export_method: "development",
                output_directory: "/Users/nsyworker/Desktop",
                output_name: "xxxFir_im",
                silent: false,
                include_symbols: true)
                firim(firim_api_token: "xxxxxxxx")
        end
    
    
        lane :applestore do
            gym(scheme: "xxx",
                 workspace: "xxx.xcworkspace",
                 include_bitcode: true,
                 configuration: "Release",
                 export_method: "app-store",
                 output_directory: "/Users/nsyworker/Desktop",
                 output_name: "xxxAppleStore",
                 silent: false,
                 include_symbols: true)
        end
    
    end
    
    

    如果要上传fir

    # 上传ipa至fir.im服务器 Fastfile加上 firim(firim_api_token: "fir-api-token")
    # 这里fir-api-token指的是fir.im上面的token
    

    但如果想打包完直接上传至fir,还需要在项目目录下,用终端或者iTerm执行命令行:

    fastlane add_plugin firim   ##安装fir插件
    gem install fir-cli     ##自动上传fir
    
    如果 `gem install fir-cli` 报了权限错误 则执行
    sudo gem install -n /usr/local/bin fir-cli --no-ri --no-rdoc
    
    
    然后再执行命令:bundle exec fastlane xxx
    (xxx 是Fastfile 里的lane名)即完成打包
    

    参考网址1
    参考网址2
    参考网址3
    参考网址4

    相关文章

      网友评论

          本文标题:利用fastlane实现iOS自动化打包并且上传到fir

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