Flutter/移动开发

fastlane自动打包上传fir

2016-10-30  本文已影响0人  yayun_he

fastlane 是什么,功能太强大,了解请移步 -->官网
fastlane git链接 -->git
1.安装fastlane

sudo gem install fastlane

安装如果太慢
可以执行尝试执行gem cleanup在次执行安装命令

如果安装过程中出现
(ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/commander)

此种情况错误(一搜一大堆),请移步(如果持续有问题,就先走安装xcode-select吧,看第三步)

sudo gem install -n /usr/local/bin fastlane

2.想要自动上传fir当然需要安装fir-cli
在安装时如果是自己的ruby则不需要加sudo,如果是mac自带的需要加sudo获取sudo权限(如果出现 Permission denied相关问题可能是没➕sudo吧,之前遇到的)
sudo gem install fir-cli

(Mac OS X 10.11 以后的版本, 由于10.11引入了 rootless
, 无法直接安装 fir-cli, 有以下三种解决办法:)

1. 使用 [Homebrew](http://brew.sh/) 及 [RVM](https://rvm.io/) 安装 Ruby, 再安装 fir-cli(推荐)
 Install Homebrew:$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"# Install RVM:
$ curl -sSL https://get.rvm.io | bash -s stable --ruby
$ gem install fir-cli
2. 指定 fir-cli 中 bin 文件的 PATH
$ export PATH=/usr/local/bin:$PATH;
gem install -n /usr/local/bin fir-cli
3. 重写 Ruby Gem 的 bindir
$ echo 'gem: --bindir /usr/local/bin' >> ~/.gemrc
$ gem install fir-cli

3.确保xcode-select是最新版本, 在终端执(没安装Homebrew的自己安装下,我认为很好用神器啊你怎么可少呢,活着直接xcode-select --install)
brew install xctool

上面一系列辅助工具安装好了,如果下面这个错误

xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance)

这个是当时我安装两个版本Xcode造成的原因,需要切换下路径

(或者
sudo xcode-select --switch 路径)```
总之s是switch的缩写, 后面跟的是xcode的路径,进入应用程序,选中你使用的xcode拖过来生成一个路径就是了(*如果你不知道路径的话*)

***好了来使用吧~***

1.cd 到你的项目目录下~
2.```fatlane init```来生成默认的Fastlane文件吧,等待...输入Apple账号密码。
3.编辑我们的fastlane文件吧

SCHEME_NAME为你的工程名,我写成了全局的,
FIR_TOKEN为你的fir的API token

设置版本号,居然不起作用.............

def prepare_version(options)
increment_version_number(
version_number: options[:version]
)
increment_build_number(
build_number: options[:build]
)
end

我导出的ipa名称此处为"工程名字+version+build.ipa"

lane :beta do |options|
# match(type: "appstore") # more information: https://codesigning.guide
prepare_version(options)
full_version = options[:version] + '_' + options[:build]

不知道此处写了个自动更新Xcode 版本号,居然没有work。。。

update_provision(typePrefix)

# match(type: "appstore") # more information: https://codesigning.guide
gym(
  scheme: "#{SCHEME_NAME}",   # 工程名
  #use_legacy_build_api: true,//升级fastlane到2.27.0后发现此处不能用,注释之后,打包自动成为企业包,解决方案,去除此句改为
  export_method: "ad-hoc",// 好几种方式有app-store,ad-hoc,development,enterprise, 
  workspace: "#{SCHEME_NAME}.xcworkspace",
  silent: true, #隐藏没有必要的文件
  clean: true,  # 编译前执行 clean,可减少 ipa 文件大小
  output_directory: "ipa的存储目录",  # 打包后的 ipa 文件存放的目录
  output_name: "#{SCHEME_NAME}_#{full_version}.ipa" , # ipa 文件名
  configuration: "Debug" #  打包方式,Release 或者 Debug
) # Build your app - more options available

sh "fir publish 'ipa文件的路径' -T #{FIR_TOKEN} "
# You can also use other beta testing services here (run `fastlane actions`)

end

4.上传fir ,-T后面是fir的token

sh "fir publish 'ipa文件路径.ipa' -T API token

5.跑起来试试吧~~cd 到项目目录下

fastlane beta version:1.0.0 build:1.0.0


看下脚本 各关键字的含义
fastlane  [git上的](https://github.com/fastlane/fastlane)


此处为copy的下面一编文章上面的解释

到Testflight 和App Store 待。。。

有没有感觉很简单啊~~


参考 :(http://www.jianshu.com/p/90358b3391d7)
参考:(https://zhuanlan.zhihu.com/p/23180455)
上一篇下一篇

猜你喜欢

热点阅读