fastlane 的集成与使用

1,360 阅读2分钟

集成

1.安装最新版的Xcode command line tools如果已经安装了则会提示如下错误

xcode-select: error: command line tools are already installed, use "Software Update" to install updates

否则会提示安装

423503-374dd837ad37c5de.jpg

2.安装fastlane

  • Using RubyGems
sudo gem install fastlane -NV
  • Alternatively using Homebrew
brew cask install fastlane

如果在使用RubyGems安装的过程中出现入下错误

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

请使用如下命令安装

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

使用

在新项目中使用fastlane cd 到项目的根目录下

fastlane init

你会看到如下步骤

image.png

在这里我们选择3。

image.png
选择完成后需要输入自己的开发者账号。

!注意这里你的项目的Bundle Identifier 是要在App Content中注册使用了的。如果这个项目只是测试,可忽略。

输入完账号之后,终端显示如下

image.png
这个时候我们选择 y 允许管理元数据 之后会这样
image.png
此时如果卡住不动,请在项目的根目录下找到Gemfile这个文件
image.png
并且将source修改改成

https://gems.ruby-china.com/

之后关闭这个终端窗口,重新进入项目的根目录下,然后执行

bundle update

这时候已经在项目中集成好了fastlane

为项目添加自动上传到fir.im

在终端进入项目的根目录,然后执行

fastlane add_plugin firim

命令,添加firim这个插件 之后在fastlane/Fastfile文件中配置信息如下

desc "Push a new app build to the fir”
  lane :bate do
    build_app(
 	clean: true,
 	workspace: "项目名称.xcworkspace”, 
  	scheme: “项目”,
     	export_method: "ad-hoc”,
     	output_directory: "./fastlane/package”,
     	configuration: “Debug”
    	)
    firim(platform: "ios”, 
   	firim_api_token: “fir.im的token”,
	icon: "./fastlane/metadata/app_icon.jpg”
   	)
  end

token 在这个获取https://fir.im/apps,在右上角的用户信息中有API token 点击即可获取。

想要打包上传fir,在终端运行

fastlane

image.png
然后选择2即可。