一瞻佛、安裝前準(zhǔn)備
開發(fā)環(huán)境:
1.OS X 10.9 (Mavericks) 以上
2.Ruby 2.0 以上
3.Xcode 最新版
4.擁有一個(gè)付費(fèi)的蘋果開發(fā)者賬號(我的賬號是加入開發(fā)組传黄,并且給我開了管理員權(quán)限器予,未付費(fèi))
二辜梳、配置環(huán)境
1撬讽、安裝xcode
2铲觉、更新ruby版本窝稿,安裝rvm
# 安裝
curl -L get.rvm.io | bash -s stable
# 測試是否安裝正常
rvm -v
# 列出已知ruby版本
rvm list known
# 安裝一個(gè)最新ruby版本 注:此處xxxxx為list中的最新版本號
rvm install ruby-xxxxx
# 如果報(bào)錯(cuò)的話
brew install openssl
# 注意修改xxxxxx
reinstall|install ruby-xxxxx
以上所需的ruby環(huán)境基本配置好了
3、打開終端访忿,選擇ruby 源
(rubygems瞧栗、taobao這兩個(gè)源不知道哪個(gè)能成功,所以都分別切換試一下海铆,后文會提到)
# 查看gem源
gem sources
# 刪除默認(rèn)的gem源
gem sources --remove https://rubygems.org/
# 增加taobao作為gem源
gem sources -a https://ruby.taobao.org/
# 查看當(dāng)前的gem源
gem sources
*** CURRENT SOURCES ***
http://ruby.taobao.org
# 清空源緩存
gem sources -c
# 更新源緩存
gem sources -u
三迹恐、安裝Fastlane
1、安裝xcode-select
xcode-select --install
# 如果 Xcode CLT 已經(jīng)安裝卧斟,則會報(bào)如下錯(cuò)誤
# command line tools are already installed, use "Software Update" to install updates.
# 如果未安裝殴边,終端會開始安裝 CLT
2.安裝fastlane
sudo gem install fastlane --verbose
# 如果報(bào)錯(cuò):ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/commander
sudo gem install -n /usr/local/bin fastlane
# 等待著安裝完畢....coffee or tea
# 安裝結(jié)束后,查看版本
fastlane --version
# 實(shí)際上目前安裝的fastlane并不是最新版本,還需要更新唆涝,怎么更新呢找都,看下面
# cd到項(xiàng)目文件夾
cd xxxxx
# 初始化文件
fastlane init
Fastlane版本號
Fastlane在項(xiàng)目文件夾初始化后產(chǎn)生的文件
四、配置文件修改
# 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.37.0"
default_platform :ios
platform :ios do
before_all do
# ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."
#cocoapods
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: "FM") # 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: "FM") # Build your app - more options available
deliver(force: true)
# frameit
end
#2.定義自定義lane 上傳到App Store
desc "自定義lane"
lane :ldd_release do
#2.1編譯 選擇scheme和功能
# 增加build版本號
increment_build_number
gym(
scheme: "FM",
workspace: "com.xxxx.xxxxx",
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
# 上傳到蒲公英
lane :ldd_beta do
gym(
export_method: "ad-hoc",
scheme: "FM"
)
pgyer(api_key: "accxxxxxxxxxb731b1c", user_key: "4f223xxxxxxxxxxxc089bb7e")
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/fastlane#metrics
五廊酣、使用
切換到項(xiàng)目根目錄下
1能耻、上傳到App Store
fastlane ldd_release
2、上傳到蒲公英
bundle exec fastlane ldd_beta