文档:https://docs.fastlane.tools/codesigning/getting-started/
https://docs.fastlane.tools/actions/build_ios_app/#parameters
2019年5月27日 \
1.成功打development包 开发包 (可以用itools安装)
desc "上传到sentry"
lane :gymsit do
#download_dsyms
gym(
configuration: "Debug-SIT",
scheme: "317hu-SIT",
workspace: "317hu.xcworkspace",
export_method: "development",
include_bitcode: false,
output_name: "317hu-SIT",
)
end
2.成功打企业版包,打出的包可以上传蒲公英
lane :gymsit do
#download_dsyms
gym(
scheme: "PICC-SIT",
workspace: "PICC.xcworkspace",
include_bitcode: false,
export_method: "enterprise",
output_name:"PICC-sit",
)
end
2018年9月6日
一.第一版本也可以直接上传appstore,
1.先在appstoreconnect创建相关引用,填上所有信息,含图片
2.在项目里删除原来的faslane文件夹,用sudo fastlane init创建上传相关文件
3.直接用fastlane qqhl_release 上传即可。
2017年5月25日
一.fastlane
主要功能:自动部署和上传 app 到应用市场(android app也可以)。
1.官网https://fastlane.tools/
文档
https://docs.fastlane.tools/
二.安装(Homebriew)其他方法参照上面文档
1 保证最新的xocde 命令工具
xcode-select --install
2.安装
brew cask install fastlane
报错 No available Cask for fastlane
解决 brew cask update
( poff 先关闭翻墙)
接下来 brew cask install fastlane
3.安装成功示意图
3.1其实上面可能还有问题
image.png
解决
echo 'export PATH="$HOME/.fastlane/bin:$PATH"' >> ~/.bash_profile
另外如果你发现.profile文件的变量不起作用了,在.bash_profile文件下如下命令既可
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
三.相关配置文件创建
1.cd到根目录
cd /Users/yanchengyi/Documents/317hu
image.png
2.初始化(输入相关信息)
fastlane init
image.png
生成如下文件
image.png2.可能会没有创建 DeliverFile等文件,继续init
deliver init //(如果报错按报错说明,用 fastlane update_fastlane 更新)
image.png
3.配置文件操作(主要是Fastflie 和 Deiverfile)
3.1.Fastflie 文件编写 (主要是定义ygy_release action,其他基本上是默认创建的)
# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command
# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`
# If you want to automatically update fastlane if a new version is available:
# update_fastlane
# This is the minimum version number required.
# Update this, if you use features of a newer version
fastlane_version "2.28.3"
default_platform :ios
platform :ios do
before_all do
# ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
#cocoapods #1.我们注释掉了,因为代码里面就有pods库代码
end
desc "Runs all the tests"
lane :test do
scan
end
desc "Submit a new Beta Build to Apple TestFlight"
desc "This will also make sure the profile is up to date"
lane :beta do
# match(type: "appstore") # more information: https://codesigning.guide
gym(scheme: "317hu") # Build your app - more options available
pilot
# sh "your_script.sh"
# You can also use other beta testing services here (run `fastlane actions`)
end
desc "Deploy a new version to the App Store"
lane :release do
# match(type: "appstore")
# snapshot
gym(scheme: "317hu") # Build your app - more options available
deliver(force: true)
# frameit
end
#2.定义自定义lane
desc "自定义lane"
lane :ygy_release do
#2.1编译 选择scheme和功能
# 增加build版本号
increment_build_number
gym(
scheme: "317hu",
workspace: "317hu.xcworkspace",
include_bitcode: false
)
deliver(
#2.2上传appstore
force: true,
# skip_metadata: true,
skip_screenshots: true,
# skip uploading an ipa or pkg to iTunes 如果有最新包ipa包上传一定要 fasle
skip_binary_upload: false,
submit_for_review: true,
automatic_release: true,
price_tier: 0
)
end
# You can define as many lanes as you want
after_all do |lane|
# This block is called, only if the executed lane was successful
# slack(
# message: "Successfully deployed new App Update."
# )
end
error do |lane, exception|
# slack(
# message: exception.message,
# success: false
# )
end
end
# More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
# All available actions: https://docs.fastlane.tools/actions
# fastlane reports which actions are used
# No personal data is recorded. Learn more at https://github.com/fastlane/enhancer
3.1.1如果设置了自动升级bulid版本号increment_build_number,工程属性需要如下设置
image.png3.2Deiverfile文件编写 (主要用来写下更新说明,以及是否有广告标识之类设置)
###################### More Options ######################
# If you want to have even more control, check out the documentation
# https://github.com/fastlane/fastlane/blob/master/deliver/Deliverfile.md
###################### Automatically generated ######################
# Feel free to remove the following line if you use fastlane (which you should)
# 1 app_identifier
app_identifier "com.317hu.xxxx" # The bundle identifier of your app
# 2 用户名,Apple ID电子邮件地址
username "xx@xx.com" # your Apple ID user
# 3 提交审核信息
submission_information({
export_compliance_encryption_updated: false,
export_compliance_uses_encryption: false,
content_rights_contains_third_party_content: false,
add_id_info_uses_idfa: true,
add_id_info_serves_ads: true,
add_id_info_limits_tracking: true
})
#4 更新说明
release_notes({
'zh-Hans' => "1、更新app图标;
2、app交互全面改版,具体内容分类显示;
3、详细内容增加字体大小设置功能。"
})
3.3 Appfile文件 (apple_id team_id账号等)
用终端命令默认创建的即可,不要特别修改
四.使用
1.切换到根目录
cd /Users/yanchengyi/Documents/317hu
fastlane ygy_release
2.成功效果(大概终端命令要执行20分钟左右)
image.png image.png image.png五.补充
1.查看 Deliverfile可以添加的元素
fastlane action deliver
image.png
2.注意事项
2.1第一次 都需要
fastlane init
或者deliver init
来创建配置文件,很多metadata里面的元素,其实都是itunes connect网站里面获取的,2.2 如果网站的内容(如联系方式,测试账号密码等)没有修改,其实不需要在init, 直接
fastlane ygy_release
(自定义用来上架appstore的action)大概终端命令要执行20分钟左右(如果5分钟,你很可能没有上传ipa, 该值一定要skip_binary_upload: false,)
2.3.很多metadata里面的元素,其实也可以在Deliverfile文件里面定义,一般优先读取Deliverfile文件,没有在读metadata
eg:
image.png
- 版本号其实是读工程这个文件的
4.编译带参数的lane 选自如下博客http://www.jianshu.com/p/840943eff17b
# 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
4.1使用:
fastlane release version:1.0.2 // 打包App Store版本ipa,app版本号为1.0.2
如果您发现本文对你有所帮助,如果您认为其他人也可能受益,请把它分享出去。
网友评论