1、安装fastlane
sudo gem install fastlane -nv或brew cask install fastlane
2 、cd工程目录 执行fastlane init命令,弹出四个选项选择第三个发布appstore(会创建一个发布到appstore的lane)
3 、提示输入开发者账号和密码
开发者账号开通安全认证 去Apple ID中心认证 设置专有app密钥 首次认证需要4天左右才能开通
4、 然后几个问题都按Yes
5、 打开 fastfile 就是我们的工作文件
6 、打包到蒲公英 安装蒲公英插件 fastlane add_plugin pgyer
7、 在fastfile文件中新建一个lane(工作区间)fastfile有一个上传appstore lane
desc "打包到pgy"
lane :test do |options|
gym(
clean:true,
#打包前clean项目
export_method: "ad-hoc",
#导出方式
scheme:"xxx", #scheme
configuration: "Debug",
#环境
output_directory:"./app",
#ipa的存放目录
output_name:"测试版本",#get_build_number()
#输出ipa的文件名为当前的build号
)
注意:蒲公英的大包证书是adhoc的product profile
#蒲公英的配置 替换为自己的api_key和user_key
pgyer(api_key: xxxxx”, user_key: “xxxx”,update_description: options[:desc])
8、App Store的lane
lane :appstore do
updateProjectBuildNumber
build_app(
workspace: "xxx.xcworkspace",
scheme: "xxx",
configuration: "Release",
export_xcargs: "-allowProvisioningUpdates",
)
upload_to_app_store
end
此处的updateProjectBuildNumber即在fastlane build时根据时间递增一个build号,当然自己可以修改成自己需要的build号,这样在同一个version的情况下就不需要手动修改build版本号了
def updateProjectBuildNumber
#puts("*************| 更新build #{build} |*************")
# => 更改项目 build 号
currentTime = Time.new.strftime("%y%m%d%H%M")
increment_build_number(
build_number: "#{currentTime}"
)
end
9、此外如果profile有调整咋办,fastlane也是支持下载更新profile的
lane :profile do
#如果没有在Apple Developer创建证书的话,get_certificates会帮你自动创建证书
get_certificates
sigh(
username: 'xxx',
app_identifier: 'xxx',
force: true,
provisioning_name: 'xxxx',
ignore_profiles_with_different_name: true,
#adhoc: true
)
end
网友评论