fastlane打包IOS

fastlane打包IOS

前言

公司准备搭建持续集成环境,ios方面选用fastlane作为打包工具,这里记录一下安装过程
fastlane 使用ruby编写,为自动化iOS和Android应用程序Beta部署和发布提供便捷方法

环境

  1. macOS Xcode 10.3
  2. ruby 2.6.5

安装fastlane

  1. 确保已安装xcode
xcode-select --install

如果已安装会提示
xcode-select: error: command line tools are already installed, use “Software Update” to install updates

  1. 安装fastlane

执行命令 二选一

# Using RubyGems
sudo gem install fastlane -NV

# Alternatively using Homebrew
brew cask install fastlane

设置环境变量

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

使用fastlane

  1. 在项目根目录执行
fastlane init

选择所有功能,会在项目中生成fastlane文件夹,文件夹中有FastfileAppfile 两个文件
Fastfile :定义fastlane配置

default_platform(:ios)

platform :ios do

  lane :initpod do |options| # 使用了cocoapods,定义初始化cocoapods
  cocoapods
  carthage(
  	platform: "ios"
  )
  end
  
  lane :beta do |options|
  if is_ci?   #是否在持续集成环境,由于以后要在持续集成环境(jenkins)中使用,需要初始化持续集成环境,options 操作可以传入参数,eg:fastlane beta kcpath:"" kcpwd:""
    setup_jenkins(
	keychain_path: options[:kcpath], #ci机器钥匙串路径
	keychain_password: options[:kcpwd] #ci机器解锁钥匙串密码
    )
  end
	  
   changelog_from_git_commits( #设置上传testflight待测功能日志,取gitcommit最新10条记录
	  commits_count: 10,
	  pretty: "- (%ae) %s",
	  date_format: "short",
	  match_lightweight_tag: false,
	  merge_commit_filtering: "exclude_merges"
	) 
	increment_build_number({
	  build_number: latest_testflight_build_number.to_i + 1  #设置上传testflight buildnumber 获取最新数字+1
	})
	  
    build_ios_app(
	scheme:"大学Stage",
        workspace: "project.xcworkspace",
        export_method: "app-store",#导出ipa类型
        export_xcargs: "-allowProvisioningUpdates",
		clean: true, #清除
        output_directory:"./build",
        output_name: "project.ipa",
        sdk: "iphoneos",
        configuration: ""
    )
    DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS="-t Aspera" #设置上传方式

    pilot(
     username: "", #apple id
     ipa: "./build/project.ipa",
     itc_provider: "",
     app_identifier: ""
    )
  end
 end

Appfile :定义apple id信息

app_identifier "" # The bundle identifier of your app
apple_id "" # Your Apple email address
team_id ""
itc_team_id ""

参考
https://docs.fastlane.tools/

遇到的问题

latest_testflight_build_number + 1 -> [!] no implicit conversion of Fixnum into String
官方给的获取testflight最新版本+1 例子是

increment_build_number({
  build_number: latest_testflight_build_number + 1
})

改为

increment_build_number({
  build_number: latest_testflight_build_number.to_i + 1
})

参考
https://github.com/fastlane/fastlane/issues/12097

证书问题

需要使用admin权限的账号登录下xcode同步一下证书

上传testflight慢
设置上传方式,这个方式需要开启防火墙,上传时会报错Communication error. Please use diagnostic mode to check connectivity. You need to have outbound access to TCP port 443 但是并不影响

DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS="-t Aspera"

参考
https://www.logcg.com/archives/3235.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值