最近在研究自动打包的东西,之前也接触过一点fastlane的东西,所以这次直接使用fastlane来进行自动化打包。
安装fastlane
关于fastlane的安装网上有好多文章,随便搜一搜就能找到
sudo gem install fastlane
就是如此简单。
安装完后可以检查一下安装是否成功
fastlane --version
fastlane installation at path:
/Library/Ruby/Gems/2.3.0/gems/fastlane-2.121.1/bin/fastlane
-----------------------------
[✔]
fastlane 2.121.1
这样就说明安装成功。
安装Xcode command line工具
xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates #说明已经安装
初始化自动化打包工程
- 首先到Xcode的工程目录下
- 然后初始化fastlane工程
fastlane init
[✔]
[✔] Looking for iOS and Android projects in current directory...
[15:58:55]: Created new folder './fastlane'.
[15:58:55]: Detected an iOS/macOS project in the current directory: 'iVMS-7880.xcworkspace'
[15:58:55]: -----------------------------
[15:58:55]: --- Welcome to fastlane ---
[15:58:55]: -----------------------------
[15:58:55]: fastlane can help you with all kinds of automation for your mobile app
[15:58:55]: We recommend automating one task first, and then gradually automating more over time
[15:58:55]: 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。也可以选择3,后面Appfile文件就不需要修改了。
- 修改
./fastlane/Appfile
文件
app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app
apple_id("[[APPLE_ID]]") # Your Apple email address
team_id("[TEAM_ID]") # Developer Portal Team ID
- 修改
./fastlane/Fastfile
文件
default_platform(:ios)
platform :ios do
desc "企业版"
lane :inhouse do
gym(
scheme:"scheme",
include_bitcode: false, #这个可以参考Xcode target->build settings -> build Options
output_directory:"./",
output_name:"test",
silent: true, #Hide all information that's not necessary while building
export_options:{ #这个可以参考手动打包出来的Exportoptions.plist
compileBitcode:false,
method:"enterprise",
provisioningProfiles: {
"bundle id" => "provisionProfile name"
}
}
)
end
end
- 进行自动化打包测试
fastlane inhouse
接下来就可以去干其它事了,当运行结束后在工程目录就会生成test.ipa包。