• 问题

    天天打包,即便面对的是肤白貌美小姐姐,终有安装识别别烦我的苦恼以及事到一半打个包的郁闷,

    咋整?

    Fastlane吧!

  • 思路

    1.xcode-select安装,确定安装了最新版本

    xcode-select --install

    2.安装fastlane, 单独安装,去掉sudo; 使用系统自带的ruby,需要sudo权限

    sudo gem install fastlane

    3.项目根目录,初始化fastlane

    fastlane init  // 命令行
    
    // 执行结果
    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
    ?  4

    4.配置下Fastfile文件

    default_platform(:ios)
    platform :ios do 
      lane :beta_release do |options|
        # 版本号设置
        increment_build_number(
          build_number: options[:buildnumber]
          )
        # 打包ipa文件
        buildapp(
          workspace: "xxx.xcworkspace",
          configuration: "Release",
          scheme: "xxx",
          export_method: "ad-hoc",
          output_name: "xxx.ipa"
          )
        
        # 上传到蒲公英
        pgyer(api_key: "xxx", user_key: "xxx", update_description: options[:message])
      end
    
      desc "build app"
      private_lane :buildapp do |options|
        gym(
          workspace: options[:workspace],
          configuration: options[:configuration],
          scheme: options[:scheme],
          clean: true,
          export_method: options[:export_method],
          output_directory: "./fastlane/package/",
          output_name: options[:output_name],
          sdk: "iphoneos"
          )
      end 
    end
    

    5.控制Version版本号设置自增

    Versioning System 设置为Apple Generic

    6.添加pgyer插件,可上传到蒲公英

    sudo fastlane add_plugin pgyer

    7.调用方式

    /usr/local/bin/fastlane beta_us_release message:"打包啦" buildnumber:101
  • 结语

    工程中的Pod执行,可放在lane中执行,或脚本执行,各凭喜好不细说,

    可能问题:

    1.出错fastlane_xcode_build_settings_timeout

    命令行中运行如下来更新timeout时间

    export FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT=120

    2.Fastlane bundle update执行卡住

    检查ruby源
    gem source -l
    
    替换源
    gem source --add https://gems.ruby-china.com/ --remove https://rubygems.org/
    
    替换Gemfile文件
    source "https://rubygems.org" 替换成  source "https://gems-china.org"
    
    删除fastlane文件夹,打开终端,cd到工程目录下,再次执行fastlane init

    3.invalid byte sequence in US_ACSII错误

    解决方法:
    export LANG=en_US.UTF-8
    export LANGUAGE=en_US.UTF-8
    export LC_ALL=en.us.UTF-8

善斋书屋
1 声望0 粉丝