美文网首页
iOS 自动打包-fastlane 命令 简单使用

iOS 自动打包-fastlane 命令 简单使用

作者: 码农斯密达 | 来源:发表于2018-12-26 17:48 被阅读5次

安装ruby、fastlane完成之后(刚需:xcode)

1:cd到项目目录初始化fastlane (类似于pod初始化)

fastlane init(中途会让选择打什么样的包,选3就好,在fastfile再指定打包方式,输入AppId、AppIdentifier) 

# 指定打包所使用的输出方式,目前支持app-store, package, ad-hoc, enterprise, development

init之后项目目录中会出现fastlane文件夹

2:蒲公英插件安装

fastlane add_plugin pgyer

3:配置好fastfile,如下

default_platform(:ios)

platform :ios do

  desc "打包到pgy"

  lane :topgyer do|option|

    #cocoapods

#carthage

    #自动增加build

    # increment_build_number

  #自动生成证书

    cert

pem

    #自动增加build

    #increment_build_number

scheme_name = "项目名称"

#获取version和build版本号

    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 = "./build"

#导出名称

    output_name = "#{scheme_name}_#{version}_#{build}_#{option[:desc]}_#{Time.now.strftime('%Y%m%d%H%M%S')}.ipa"

    gym(

# 指定打包所使用的输出方式,目前支持app-store, package, ad-hoc, enterprise, development

      export_method: "ad-hoc",

      scheme: scheme_name,

      clean: true,

      output_directory: output_directory,

      output_name: output_name

    )

    pgyer(api_key: "蒲公英api_key", user_key: "蒲公英user_key", update_description: "#{option[:desc]}")

  end

end

在配置电脑上放上证书

注意证书要正确!注意证书要正确!注意证书要正确!

证书不要特意去设置始终信任,系统默认的就好。

打包时在配置电脑会让输入一下密码来使用证书!

4: fastlane topgyer(topgyer可在Fastfile中设置)

完工!!!

希望可以对你有所帮助~

相关Jenkins自动部署还未做整理~


相关文章

网友评论

      本文标题:iOS 自动打包-fastlane 命令 简单使用

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