1 本文只是fastlane的基本使用.fastlane (二)有更多講解
2 使用fastlane前,確保你已經(jīng)可以使用Xcode手動(dòng)打包成功(說明你已經(jīng)配置好證書)
1.配置環(huán)境
1.安裝HomeBrew
#安裝
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#更新到最新版
brew update
#更新包
brew upgrade
2.安裝ruby
#安裝
brew install ruby
#查看版本
ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
3.安裝fastlane
#安裝
sudo gem install fastlane -NV
#查看版本
fastlane -v
fastlane installation at path:
/Library/Ruby/Gems/2.3.0/gems/fastlane-2.102.0/bin/fastlane
-----------------------------
[?] ??
fastlane 2.102.0
配置環(huán)境結(jié)束劫瞳,應(yīng)該沒什么難度.
2.使用 fastlane
1.先cd到項(xiàng)目路徑
cd /Users/yu/Documents/MyApp
2.初始化 fastlane (一個(gè)項(xiàng)目的第一次需要)
fastlane init
[?] ??
[?] Looking for iOS and Android projects in current directory...
[17:22:06]: Created new folder './fastlane'.
[17:22:06]: Detected an iOS/macOS project in the current directory: 'Daily.xcworkspace'
[17:22:06]: -----------------------------
[17:22:06]: --- Welcome to fastlane ?? ---
[17:22:06]: -----------------------------
[17:22:06]: fastlane can help you with all kinds of automation for your mobile app
[17:22:06]: We recommend automating one task first, and then gradually automating more over time
[17:22:06]: What would you like to use fastlane for?
1. ?? Automate screenshots
2. ????? Automate beta distribution to TestFlight
3. ?? Automate App Store distribution
4. ?? Manual setup - manually setup your project to automate your tasks
我們選擇4,輸入4,然后回車就可以了剪侮。
? 4
[17:22:17]: ------------------------------------------------------------
[17:22:17]: --- Setting up fastlane so you can manually configure it ---
[17:22:17]: ------------------------------------------------------------
[17:22:17]: Installing dependencies for you...
[17:22:17]: $ bundle update
看到上面的輸出后沃疮,在我們項(xiàng)目路徑下已經(jīng)生成fastlane文件了求橄。
點(diǎn)開發(fā)現(xiàn)有2個(gè)文件 Appfile 和 Fastfile 2個(gè)文件镇匀。
3.編寫Appfile和Fastfile 文件
Appfile文件
# app_identifier("yu.xx.MyApp") # The bundle identifier of your app
# apple_id("appld@outlook.com") # Your Apple email address
# itc_team_id
team_id "43XXXXXX9K" # Developer Portal Team ID
# For more information about the Appfile, see:
# https://docs.fastlane.tools/advanced/#appfile
Fastfile文件
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:ios)
platform :ios do
desc "Description of what the lane does"
lane :keji do
build_app(workspace:"MyApp.xcworkspace",
scheme:"MyApp",
export_method:"development",
output_directory:"./fastlane/ipadFile",
configuration:"Debug")
end
end
??注意
查找team_id:在你用Xcode手動(dòng)打包后钮莲,生成的文件中(MyApp 2018-08-17 14-33-14)免钻。ExportOptions.plist這個(gè)文件中包含team_id。
4.打包
最后的時(shí)候我們執(zhí)行打包就可以了
fastlane MyApp
MyApp是你的項(xiàng)目文件名
顯示打包成功后崔拥,在MyApp/fastlane/ipadFile中就能看到ipa包了极舔。??
3.擴(kuò)展
1.ipa自動(dòng)發(fā)布
自動(dòng)打包成功后,當(dāng)然需要自動(dòng)發(fā)布到蒲公英链瓦,或者fir了拆魏。以蒲公英為例子:
1 安裝蒲公英的 Fastlane 插件:
fastlane add_plugin pgyer
2 修改Fastfile文件
default_platform(:ios)
platform :ios do
desc "Description of what the lane does"
lane :keji do
build_app(workspace:"MyApp.xcworkspace",
scheme:"MyApp",
export_method:"development",
output_directory:"./fastlane/ipadFile",
configuration:"Debug")
pgyer(api_key: "7f15xxxxxxxxxxxxxxxxxx141", user_key: "4a5bcxxxxxxxxxxxxxxx3a9e", update_description: "update by fastlane")
end
end
使用 Fastlane 上傳 App 到蒲公英API
https://www.pgyer.com/doc/view/fastlane
4.更多
關(guān)于更多擴(kuò)展iOS 自動(dòng)打包 - fastlane (二)