1.运行命令,安装fastLane
sudo gem install -n /usr/local/bin fastlane --pre
2.用cd命令到项目目录下
3.运行命令,初始化fastLane
fastlane init
过程中会要求输入apple id和密码
4.运行命令,安装蒲公英插件
fastlane add_plugin pgyer
如果之前目录下没有Gemfile,会自动生成一个,需要在里面改一下
source "https://gems.ruby-china.org/"
gem 'cocoapods'
加入这两句
5.打开目录下fastlane/Fastfile文件,在文件中加入下面代码
desc "ipa打包"
lane :createIpa do
scheme_name = 'xxx'
configuration = 'Debug'
date = Time.now.strftime('%Y%m%d%H%M%S')
version = get_info_plist_value(path: "./#{scheme_name}/Info.plist", key: "CFBundleShortVersionString")
build = get_info_plist_value(path: "./#{scheme_name}/Info.plist", key: "CFBundleVersion")
output_directory = File.expand_path("..", Dir.pwd) + File::Separator + 'build/' + #{date}
output_name = "#{date}.ipa"
#sigh(adhoc:true) #如果要使用ad-hoc打包, 则需打开此项配置
gym(scheme: "xxx",
workspace: "xxx.xcworkspace", # 可省略
configuration: configuration, # Debug or Release
clean: true, #清空上次打包信息
output_directory: output_directory,
output_name: output_name,
export_method:"development" # app-store, ad-hoc, package, enterprise, development, developer-id
)
#使用自动证书管理
enable_automatic_code_signing(path: "xxx.xcodeproj")
pgyer(api_key: "xxx", user_key: "xxx", password: "xxx", install_type: "2")
end
6.运行命令,发布完成
bundle exec fastlane createIpa
如果出现版本问题,在Fastfile中修改一下版本号