1、檢查Mac是否已經(jīng)安裝ruby:
終端或者iTerm執(zhí)行命令行:ruby -v
2、檢查本地是否安裝Xcode命令行工具:
終端或者iTerm執(zhí)行命令行:xcode-select --install
3、安裝fastlane:
終端或者iTerm執(zhí)行命令行:
sudo gem install fastlane
如果有安裝Homebrew:
brew install fastlane
4、切換到工程所在目錄進行fastlane初始化:
終端或者ITerm執(zhí)行命令行:fastlane init
會出現(xiàn)4個選項
第1個選項的意思是:自動截屏。 這個功能能幫我們自動截取APP中的截圖;
第2個選項的意思是:自動發(fā)布beta版本用于TestFlight;
第3個選項的意思是:自動發(fā)布到AppStore;
第4個選項的意思是:手動設(shè)置。
如果bundle update卡住無響應(yīng),https://rubygems.org/這個網(wǎng)址因為域名的原因停止使用了
1.首先在終端檢查ruby源 `gem source -l` 檢查`https://gems.ruby-china.com/`
如果不是請?zhí)鎿Q下
`gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.com/`
2.打開工程中的Gemfile文件
source "https://rubygems.org"
替換為
source "https://gems-china.com"
如果是用cocopod管理的項目 請加上
gem "cocoapods"
3.刪除fastlane文件夾,打開終端,cd到工程中,再次執(zhí)行fastlane init
5、初始化完成之后,回到工程目錄,會發(fā)現(xiàn)多了Gemfile文件、Gemfile.lock文件和fastlane文件夾,其中fastlane文件夾中包含Appfile和Fastfile兩個文件。
在Appfile文件里做好配置:主要就是bundle id
以下是直接針對不同的lane設(shè)置bundleId
for_lane :xxxTest do
app_identifier "com.xxx.xxx.test"
end
for_lane :xxx do
app_identifier "com.xxx.xxx"
end
在Fastfile文件里做如下配置:可以配置多個lane
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
# 好幾種方式有app-store,ad-hoc,development,enterprise
default_platform(:ios)
platform :ios do
desc "fir.im日常更新"
lane :xxxTest do
gym(scheme: "xxxTest",
workspace: "xxx.xcworkspace",
include_bitcode: true,
configuration: "Release",
export_method: "development",
output_directory: "/Users/nsyworker/Desktop",
output_name: "xxx測試版",
silent: false,
include_symbols: true)
firim(firim_api_token: "xxxxxxxxx")
end
lane :xxx do
gym(scheme: "xxx",
workspace: "xxx.xcworkspace",
include_bitcode: true,
configuration: "Release",
export_method: "development",
output_directory: "/Users/nsyworker/Desktop",
output_name: "xxxFir_im",
silent: false,
include_symbols: true)
firim(firim_api_token: "xxxxxxxx")
end
lane :applestore do
gym(scheme: "xxx",
workspace: "xxx.xcworkspace",
include_bitcode: true,
configuration: "Release",
export_method: "app-store",
output_directory: "/Users/nsyworker/Desktop",
output_name: "xxxAppleStore",
silent: false,
include_symbols: true)
end
end
如果要上傳fir
# 上傳ipa至fir.im服務(wù)器 Fastfile加上 firim(firim_api_token: "fir-api-token")
# 這里fir-api-token指的是fir.im上面的token
但如果想打包完直接上傳至fir,還需要在項目目錄下,用終端或者iTerm執(zhí)行命令行:
fastlane add_plugin firim ##安裝fir插件
gem install fir-cli ##自動上傳fir
如果 `gem install fir-cli` 報了權(quán)限錯誤 則執(zhí)行
sudo gem install -n /usr/local/bin fir-cli --no-ri --no-rdoc
然后再執(zhí)行命令:bundle exec fastlane xxx
(xxx 是Fastfile 里的lane名)即完成打包