一、shell脚本自动化打包并上传
脚本下载:https://gitee.com/jiahongling/autoPackShell.git
plist配置
在终端执行脚本
$ ./shell
二、fastlane
fastlane安装
$ sudo gem install fastlane
fastlane使用
fastlane注意点:
选择上传不同的平台:
错误原因
设置build自增
配置Fastfile文件:
添加上传平台
platform :ios do
desc "Push a new beta build to TestFlight"
lane :beta do
increment_build_number(xcodeproj: "ShellTest.xcodeproj")
build_app(workspace: "ShellTest.xcworkspace", scheme: "ShellTest")
upload_to_testflight
end
desc "Push a new release build to the 蒲公英"
lane :pgyAction do
increment_build_number(xcodeproj: "ShellTest.xcodeproj")
build_app(workspace: "ShellTest.xcworkspace", scheme: "ShellTest")
# 插件 --- 蒲公英
#fastlane search_plugins 查找插件
# fastlane add_plugin pgyer
# fastlane add_plugin firim
# fastlane add_plugin fastlane-plugin-version
pgyer(api_key:"xxx", user_key:"xxx")
end
desc "Push a new release build to the firim"
lane :firimAction do
increment_build_number(xcodeproj: "ShellTest.xcodeproj")
build_app(workspace: "ShellTest.xcworkspace", scheme: "ShellTest")
firim(firim_api_token:"xxx")
end
end
添加插件
$ fastlane add_plugin pgyer //蒲公英插件
$ fastlane add_plugin firim //fir插件
$ fastlane add_plugin fastlane-plugin-version //控制版本插件
上传appstore test flight firim 蒲公英的Appfile,Fastfile和隐藏文件.evn中的内容为:
Appfile
app_identifier ENV['App_Identifier']
apple_id ENV['Apple_Id']
itc_team_id ENV['Itc_Team_Id']
team_id ENV['Team_Id']
Fastfile
# 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)
platform :ios do
before_all do
#双重认证时用到
ENV["FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD"] = "rxpc-vbrs-very-wbrq"
cocoapods(use_bundle_exec: FALSE)
puts "所有任务执行开始了"
end
desc "上线 App Store"
lane :release do | options |
increment_build_number(xcodeproj: ENV['Xcodeproj'])
build_app(workspace: ENV['Workspace'], scheme: ENV['Scheme'])
upload_to_app_store
end
desc "上线 testflight"
lane :beta do | options |
increment_build_number(xcodeproj: ENV['Xcodeproj'])
build_app(workspace: ENV['Workspace'], scheme: ENV['Scheme'])
upload_to_testflight
end
desc "上线蒲公英"
lane :adhoc_pgy do |options|
increment_build_number(xcodeproj:ENV['Xcodeproj'])
currentTime = Time.new.strftime("%Y-%m-%d-%H-%M-%s")
logDirectory = "#{currentTime}.ipa"
build_app(
workspace: ENV['Workspace'],
scheme: ENV['Scheme'],
#configuration: "Debug",默认是Release模式,最终生成.ipa和.app.dSYM.zip,Debug模式不会生产.app.dSYM.zip,只生产.ipa
silent: true,
clean: true, #打包前clean项目
output_directory: ENV['Pgy_Output_Path'],
output_name: logDirectory,
export_xcargs: "-allowProvisioningUpdates",
export_method:"enterprise" #导出方式
)
#export_method: app-store、ad-hoc、development、enterprise
pgyer(api_key: ENV['Api_Key'],
user_key: ENV['User_Key'])
end
desc "上线firim"
lane :adhoc_firim do |options|
#increment_build_number(xcodeproj:ENV['Xcodeproj'])#该句作用:build自增
#setup_version_build是一个函数,可以自定义version和build
setup_version_build(options)#例如:fastlane adhoc_firim version:13.1 build:2
build_app(
workspace: ENV['Workspace'],
scheme: ENV['Workspace'],
#configuration: "Debug",
silent: true,
clean: true,
output_directory: ENV['Firim_Output_Path'],
output_name: "MY.ipa",
export_xcargs: "-allowProvisioningUpdates",
export_method:"enterprise")
firim(firim_api_token:ENV['Firim_Token'])
end
desc "版本处理"
def setup_version_build(options)
increment_build_number(
build_number:options[:build]
)
increment_version_number(
version_number:options[:version]
)
end
after_all do |lane, options|
puts"结束了"
end
error do |lane, exception, options|
if options[:debug]
puts "Hi :)"
end
end
end
.evn
# bundle id
App_Identifier = "xxx"
# 开发者账号 qi
Apple_Id = "xxx"
# 开发者App Store Connect Team ID
Itc_Team_Id = "xxx"
# 开发者TeamId
Team_Id = "xxx"
# project的target scheme名称
Scheme = "ShellTest"
# 项目xcodeproj
Xcodeproj ="ShellTest.xcodeproj"
# 项目xcworkspace
Workspace="ShellTest.xcworkspace"
# ipa输出路径-- Appstore
Appstore_Output_Path = "build/appstore"
# ipa输出路径-- Firim
Firim_Output_Path = "build/firim"
# ipa输出路径-- 蒲公英
Pgy_Output_Path = "build/pgy"
# firim 的token
Firim_Token = "xxx"
# 蒲公英 的api_key
Api_Key = "xxx"
# 蒲公英 的user_key
User_Key = "xxx"
说明:
xcodebuild API //www.greatytc.com/p/c32263138af3