1.准备工作
1.通过Homebrew安装fastlane
Homebrew官网,输入命令行:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装的过程中出现以下的问题,咨询是因为CN这边的网络问题,谷歌了一些解决方案。
在出现successful的时候,表示成功安装Homebrew。
2.蒲公英插件安装
目前只有这一步没有完成,其他的都符合。
Xcode命令行工具安装
xcode-select --install
只发了测试包,所以在选择fastlan的时候,选择了第4项
3.注意事项
执行该命令需要先 cd 到目标工程文件目录中执行。
fastlane add_plugin pgyer
fastlane init
替换脚本文件 Fastfile
需要在git中忽略这些文件,不能提交。
脚本参考
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
#公共设置宏定义
SCHEME = "xxx" #项目名称
EXPORT_METHOD = "ad-hoc" #ad-hoc development enterprise
OUTPUT_PREFIX = "xxx" #包名前缀
OUTPUT_DIR = "./build/" #打包输出目录
#蒲公英
APP_KEY = ""
USER_KEY = ""
platform :ios do
#测试环境
lane :test do
gym(
scheme: "#{SCHEME}",
export_method:"#{EXPORT_METHOD}",
output_name:"#{OUTPUT_PREFIX}Test.ipa",
output_directory:"#{OUTPUT_DIR}",
configuration: "Test",
)
pgyer(api_key: "#{APP_KEY}", user_key: "#{USER_KEY}")
end
lane :pre do
gym(
scheme: "#{SCHEME}",
export_method:"#{EXPORT_METHOD}",
output_name:"#{OUTPUT_PREFIX}pre.ipa",
output_directory:"#{OUTPUT_DIR}",
configuration: "PRETEST",
)
pgyer(api_key: "#{APP_KEY}", user_key: "#{USER_KEY}")
end
#生产环境
lane :release do
gym(
scheme: "#{SCHEME}",
export_method:"#{EXPORT_METHOD}",
output_name:"#{OUTPUT_PREFIX}.ipa",
output_directory:"#{OUTPUT_DIR}",
configuration:"Release",
)
pgyer(api_key: "#{APP_KEY}", user_key: "#{USER_KEY}")
end
end
执行:
fastlane test
成功即可打开pgy下载
// 更新2021-10-25 17:59:24
** EXPORT FAILED **
[17:28:29]: Exit status: 70
Looks like fastlane ran into a build/archive error with your project
网上说的是证书管理有问题,有人说是改成手动管理就可以,我没试,我只是把脚本文件中配置的
ad-hoc改成development重新打包就可以。本来只是用来测试,还可以凑合着用,如果有人发现更好的方法,可以给我留言。