关于fastlane自动化打包

fastlane(自动化打包)

安装:

sudo gem install -n /usr/local/bin fastlane
复制代码

1.在工程目录下,会在工程下生成fastlane文件夹

fastlane init
复制代码

然后会让你输入开发者账号和密码

自定义fastFile文件编写

  • appStore版本
# You can define as many lanes as you want
desc "Deploy a new version to the App Store"
lane :release do |op|
    increment_version_number(version_number: op[:version]) #根据入参version获取app版本号
    increment_build_number(build_number: op[:version])  #将build号设置与app版本号相同

    # 设置app的info.plist文件项
    set_info_plist_value(path: "./xxx/Info.plist",  #info.plist文件目录
                        key: "UIFileSharingEnabled",  # key,将plist文件以Source Code形式打开可查询对应的key
                        value: false)  # value

    # 设置自定义plist文件项,用于给app配置不同的服务器URL
    set_info_plist_value(path: "./xxx/hostAddress.plist",
                        key: "host",
                        value: "https:/zhengshiServer:xx/xxx/xxx")

    # 更新Provisioning Profile
    # 在项目当前目录下创建provisions文件夹,并将App Store版本的.mobileprovision文件保存在里面,名称随意。
    update_project_provisioning(profile: "./provisions/appstore.mobileprovision")

    # 更新项目团队
    update_project_team(path: "xxx.xcodeproj",
                  teamid: "5JC8GZ432G")

    # 开始打包
    gym(use_legacy_build_api: true,
        output_name: "appstore",  # 输出的ipa名称
        silent: true,  # 隐藏没有必要的信息
        clean: true,  # 在构建前先clean
        configuration: "Release",  # 配置为Release版本
        codesigning_identity: "iPhone Distribution: xxx Co.,Ltd. (5JC8GZ432G)",  # 代码签名证书
        buildlog_path: "./fastlanelog",  # fastlane构建ipa的日志输出目录
        output_directory: "/Users/xxx/Desktop")  # ipa输出目录

end
复制代码
  • 测试版本
desc "Build a new version use the ceshi"
lane :ceshi do |op|
    increment_version_number(version_number: op[:version])
    increment_build_number(build_number: op[:version])

    set_info_plist_value(path: "./xxx/Info.plist",
                        key: "UIFileSharingEnabled",
                        value: true)

    set_info_plist_value(path: "./xxx/hostAddress.plist",
                        key: "host",
                        value: "https:/ceshiServer:xx/xxx/xxx")

    # 将Development版本的.mobileprovision文件保存在里面,名称随意。
    update_project_provisioning(profile: "./provisions/development.mobileprovision")

    update_project_team(path: "xxx.xcodeproj",
                  teamid: "5JC8GZ432G")

    gym(use_legacy_build_api: true,
        output_name: "ceshi",
        silent: true,
        clean: true,
        configuration: "Debug",
        buildlog_path: "./fastlanelog",
        codesigning_identity: "iPhone Developer: xxx (xxxxxxxxxx)",
        output_directory: "/Users/xxx/Desktop"
  )
end
复制代码
  • 批量处理
desc "build all version ipa"
lane :all do |op|
    t = op[:version]
    ceshi version:t
    release version:t
end
复制代码

执行命令输出对应的ipa

fastlane ceshi version:1.0.0 // 打包ceshi环境ipa,app版本号为1.0.0
fastlane release version:1.0.0 // 打包App Store版本ipa,app版本号为1.0.0
fastlane all version:1.0.0 // 打包ceshi、App Store版本ipa,app版本号为1.0.0
复制代码

最终成功的方案eg:

fastlane自动化打包

ad-hoc版本:

desc "Build a new version use the ceshi"
lane :ceshi do |op|
    increment_version_number(version_number: op[:version])
    increment_build_number(build_number: op[:version])

    set_info_plist_value(path: “./xxxx/Info.plist", # 工程中的plist文件
                        key: "UIFileSharingEnabled",
                        value: true)

    set_info_plist_value(path: “./xxxxx/hostAddress.plist",
                        key: "host",
                        value: "https://www.xxxx.com/“)

    # 将Development版本的.mobileprovision文件保存在里面,名称随意。
    update_project_provisioning(profile: "./xxxxx/provisions/Distribution_adhoc.mobileprovision")

    update_project_team(path: “xxxx.xcodeproj",
                  teamid: "9Z4ZJ5K398")

    # 开始打包
    gym(# use_legacy_build_api: true,
	scheme: "xxxxxxx",
        output_name: “xxxxxx”,  # 输出的ipa名称
        silent: true,  # 隐藏没有必要的信息
        clean: true,  # 在构建前先clean
        configuration: "Debug",  # 配置为Release版本
        codesigning_identity: “iPhone Distribution: xxxxxx Network Technology Co., Ltd. (9Z4Zj5K398)”,  # 代码签名证书
        export_method:’ad-hoc’,	#指定打包所使用的输出方式,目前支持app-store, package, ad-hoc, enterprise, development, 和developer-id,即xcodebuild的method参数
        buildlog_path: "./fastlanelog",  # fastlane构建ipa的日志输出目录
        output_directory: "./fastlane")  # ipa输出目录
end
复制代码

在使用fastlane遇到的问题

  • 1.gem路径找不到问题 解决办法----卸载fastlane重装
  • 2.关掉Bitcode
  • 3.手动管理证书
  • 4.关于Fastfile的问题
      • 1.配置工程Info.plist路径
      • 2.新建hostAddress.plist,并配置好路径(功能是设置服务器地址)
      • 3.添加mobileprovision配置文件(配置的文件名和路经要正确)
      • 4.配置你工程xxxx.xcodeprojteamid(每个开发者账号都会对应一个teamid)
      • 5.gym的配置
            gym(# use_legacy_build_api: true,
        复制代码
    scheme: "xxxx", output_name: “xxxxx”, # 输出的ipa名称 silent: true, # 隐藏没有必要的信息 clean: true, # 在构建前先clean configuration: "Debug", # 配置为Release版本 codesigning_identity: “iPhone Distribution: xxxxx Network Technology Co., Ltd. (9Z4ZJ987368)”, # 代码签名证书(在钥匙串中可以找到) export_method:’ad-hoc’, #指定打包所使用的输出方式,目前支持app-store(不写则默认), package, ad-hoc, enterprise, development, 和developer-id,即xcodebuild的method参数 buildlog_path: "./fastlanelog", # fastlane构建ipa的日志输出目录 output_directory: "./fastlane") # ipa输出目录 ```
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值