Fastlane - 利用Fastfile脚本打包

作者: 沈宥 | 来源:发表于2016-12-01 14:00 被阅读273次

发现直接利用gym命令行打包过于麻烦,直接编写了脚本执行:

default_platform :ios
platform :ios do
    before_all do
    git_pull
end

#打包配置
#版本号
version = get_version_number(xcodeproj: "Project.xcodeproj")
#build number自动加1
build_number = increment_build_number
plist_path = "./Info.plist"
set_info_plist_value(path: "#{plist_path}", key: "CFBundleVersion", value: "#{build_number}")
#打包时间记录
time = Time.new
timeString = time.strftime("%Y-%m-%d_%H:%M:%S")
project_path = "Project根目录"
workspace = "#{project_path}/your workspace.xcworkspace"
output_directory = "#{project_path}/APP"
output_name = "#{version}_#{build_number}_#{timeString}.ipa"

lane :release do
gym(
workspace: "#{workspace}",
configuration: "Release",
scheme: "Scheme Name",
export_method: "ad-hoc",
clean: true,
# Destination directory. Defaults to current directory.
output_directory: "#{output_directory}",

# specify the name of the .ipa file to generate (including file extension)
output_name: "day_inke_release_#{output_name}",     
silent: false,
include_symbols: true,
use_legacy_build_api: true
)

#上传到fir.im
system "fir publish #{output_directory}/day_inke_release_#{output_name} -T Your TokenId "
end
end

备注:注意脚本中斜体部分,修改为自己的配置。
cd到工程根目录下,运行命令为:fastlane release
静待出包(注意,打包前,工程的证书设置一定要正确)

相关文章

网友评论

  • 紅塵忘:楼主你好,请问fastlane运行 system system "fir me"(fir-cli已安装,集成就报错)
    /Users/aone/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/rubygems_integration.rb:393:in `block in replace_bin_path': can't find executable fir (Gem::Exception)
    from /Users/aone/.rvm/gems/ruby-2.3.0/gems/bundler-1.13.6/lib/bundler/rubygems_integration.rb:410:in `block in replace_bin_path'
    from /Users/aone/.rvm/gems/ruby-2.3.0/bin/fir:22:in `<main>'
    from /Users/aone/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
    from /Users/aone/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
    沈宥:@紅塵忘 不是环境变量的问题,fastlane因为在执行fastlane init时是在工程的根目录,所以执行具体的lane的时候需要先cd到你工程根目录下:fastlane upFir。
    紅塵忘: lane :upFir do
    #上传到fir.im 出错,fir命令无法执行
    system "fir me"
    end

    就这一条,我以为是gym的环境变量没有配置什么的,我简简单单的运行这一条都会出错,现在搞的只能用shell 执行fastlane再执行fir。你在ruby下配置了fir环境变量了没有?我的系统版本是:10.12.1
    沈宥:@紅塵忘 能把你完整的脚本给我看一下吗?从报错中的信息可以看到是"can't find executable fir ",无法执行fir

本文标题:Fastlane - 利用Fastfile脚本打包

本文链接:https://www.haomeiwen.com/subject/ecmxmttx.html