搭建fastlane环境

通过fastlane打包发布ios的ipa

$ sudo gem install fastlane
...略
fastlane after 387 seconds
70 gems installed

通过gem install fastlane安装之后.还是没找到可执行文件安装位置,此时需要修改一下PATH环境变量

$ fastlane init
zsh: command not found: fastlane

查看fastlane所安装位置

$ gem which fastlane
/usr/local/lib/ruby/gems/3.1.0/gems/fastlane-2.220.0/fastlane/lib/fastlane.rb

进入gem目录对应bin,找到了fastlane可执行文件所在位置

$ cd /usr/local/lib/ruby/gems/3.1.0/bin
$ ls
fastlane bundle bundler

设置环境变量 此步骤略过…

fastlane安装完成…运行检查命令

$ fastlane -version
[] 🚀 
[18:51:53]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
fastlane 2.220.0

进入项目ios目录下

$ fastlane init     
[] 🚀 
[18:52:14]: Sending anonymous analytics information
[18:52:14]: Learn more at https://docs.fastlane.tools/#metrics
[18:52:14]: No personal or sensitive data is sent.
[18:52:14]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
[] Looking for iOS and Android projects in current directory...
[18:52:15]: Created new folder './fastlane'.
[18:52:15]: Detected an iOS/macOS project in the current directory: 'Runner.xcworkspace'
[18:52:15]: -----------------------------
[18:52:15]: --- Welcome to fastlane 🚀 ---
[18:52:15]: -----------------------------
[18:52:15]: fastlane can help you with all kinds of automation for your mobile app
[18:52:15]: We recommend automating one task first, and then gradually automating more over time
[18:52:15]: 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
[18:55:56]: ------------------------------------------------------------
[18:55:56]: --- Setting up fastlane so you can manually configure it ---
[18:55:56]: ------------------------------------------------------------
[18:55:56]: --------------------------------------------------------
[18:55:56]: --- ✅  Successfully generated fastlane configuration ---
[18:55:56]: --------------------------------------------------------
[18:55:56]: Generated Fastfile at path `./fastlane/Fastfile`
[18:55:56]: Generated Appfile at path `./fastlane/Appfile`
[18:55:56]: Gemfile and Gemfile.lock at path `Gemfile`
[18:55:56]: Please check the newly generated configuration files into git along with your project
[18:55:56]: This way everyone in your team can benefit from your fastlane setup
[18:55:56]: Continue by pressing Enter ⏎

[18:56:04]: fastlane will collect the number of errors for each action to detect integration issues
[18:56:04]: No sensitive/private information will be uploaded, more information: https://docs.fastlane.tools/#metrics
[18:56:04]: ----------------------
[18:56:04]: --- fastlane lanes ---
[18:56:04]: ----------------------
[18:56:04]: fastlane uses a `Fastfile` to store the automation configuration
[18:56:04]: Within that, you'll see different lanes.
[18:56:04]: Each is there to automate a different task, like screenshots, code signing, or pushing new releases
[18:56:04]: Continue by pressing Enter ⏎

[18:56:06]: --------------------------------------
[18:56:06]: --- How to customize your Fastfile ---
[18:56:06]: --------------------------------------
[18:56:06]: Use a text editor of your choice to open the newly created Fastfile and take a look
[18:56:06]: You can now edit the available lanes and actions to customize the setup to fit your needs
[18:56:06]: To get a list of all the available actions, open https://docs.fastlane.tools/actions
[18:56:06]: Continue by pressing Enter ⏎

[18:56:08]: ------------------------------
[18:56:08]: --- Where to go from here? ---
[18:56:08]: ------------------------------
[18:56:08]: 📸  Learn more about how to automatically generate localized App Store screenshots:
[18:56:08]:             https://docs.fastlane.tools/getting-started/ios/screenshots/
[18:56:08]: 👩‍✈️  Learn more about distribution to beta testing services:
[18:56:08]:             https://docs.fastlane.tools/getting-started/ios/beta-deployment/
[18:56:08]: 🚀  Learn more about how to automate the App Store release process:
[18:56:08]:             https://docs.fastlane.tools/getting-started/ios/appstore-deployment/
[18:56:08]: 👩‍⚕️  Learn more about how to setup code signing with fastlane
[18:56:08]:             https://docs.fastlane.tools/codesigning/getting-started/
[18:56:08]: 
[18:56:08]: To try your new fastlane setup, just enter and run
[18:56:08]: $ fastlane custom_lane

安装pgyer插件

sudo fastlane add_plugin pgyer
[] 🚀 
[20:14:50]: fastlane detected a Gemfile in the current directory
[20:14:50]: However, it seems like you didn't use `bundle exec`
[20:14:50]: To launch fastlane faster, please use
[20:14:50]: 
[20:14:50]: $ bundle exec fastlane add_plugin pgyer
[20:14:50]: 
[20:14:50]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[20:14:52]: Installing Ruby gem 'fastlane-plugin-pgyer'...
Fetching fastlane-plugin-pgyer-0.2.8.gem
[20:14:59]: Successfully installed 'fastlane-plugin-pgyer'
+------------------------------------------+
|               Used plugins               |
+-----------------------+---------+--------+
| Plugin                | Version | Action |
+-----------------------+---------+--------+
| fastlane-plugin-pgyer | 0.2.8   | pgyer  |
+-----------------------+---------+--------+

[20:14:59]: Make sure to commit your Gemfile, Gemfile.lock and Pluginfile to version control
Installing plugin dependencies...
Ignoring ffi-1.13.1 because its extensions are not built. Try: gem pristine ffi --version 1.13.1
Ignoring iStats-1.6.1 because its extensions are not built. Try: gem pristine iStats --version 1.6.1
Ignoring ffi-1.13.1 because its extensions are not built. Try: gem pristine ffi --version 1.13.1
Ignoring iStats-1.6.1 because its extensions are not built. Try: gem pristine iStats --version 1.6.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/nkf-0.2.0/ext/nkf
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20240427-77790-1yvojvg.rb extconf.rb
creating Makefile

current directory: /Library/Ruby/Gems/2.6.0/gems/nkf-0.2.0/ext/nkf
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.6.0/gems/nkf-0.2.0/ext/nkf
make "DESTDIR="
make: *** No rule to make target
`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin21/ruby/config.h',
needed by 'nkf.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/nkf-0.2.0 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/nkf-0.2.0/gem_make.out

An error occurred while installing nkf (0.2.0), and Bundler cannot continue.
Make sure that `gem install nkf -v '0.2.0' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  fastlane was resolved to 2.220.0, which depends on
    simctl was resolved to 1.6.10, which depends on
      CFPropertyList was resolved to 3.0.7, which depends on
        nkf

上面的错误是是因为系统的默认ruby版本不对, 重新安装的ruby新版本

$ ruby -v
ruby 2.6.10p210
# 安装ruby版本管理工具
$ brew install rbenv
...略
$ rbenv -h                                                        
Usage: rbenv <command> [<args>]

Some useful rbenv commands are:
   commands    List all available rbenv commands
   local       Set or show the local application-specific Ruby version
   global      Set or show the global Ruby version
   shell       Set or show the shell-specific Ruby version
   install     Install a Ruby version using ruby-build
   uninstall   Uninstall a specific Ruby version
   rehash      Rehash rbenv shims (run this after installing executables)
   version     Show the current Ruby version and its origin
   versions    List installed Ruby versions
   which       Display the full path to an executable
   whence      List all Ruby versions that contain the given executable

See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/rbenv/rbenv#readme`

升级版本

$ rbenv versions
* system // 只有一个版本
// 安装新的版本
$ rbenv install 3.1.1
	...略
// 安装之后..
$ rbenv versions
  system
* 3.1.1 (set by /Users/apple/.rbenv/version)
% ruby -v
ruby 3.1.1p18

再来重新安装pgyer插件

% sudo fastlane add_plugin pgyer
Password:
[✔] 🚀 
[21:57:08]: fastlane detected a Gemfile in the current directory
[21:57:08]: However, it seems like you didn't use `bundle exec`
[21:57:08]: To launch fastlane faster, please use
[21:57:08]: 
[21:57:08]: $ bundle exec fastlane add_plugin pgyer
[21:57:08]: 
[21:57:08]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
+------------------------------------------+
|               Used plugins               |
+-----------------------+---------+--------+
| Plugin                | Version | Action |
+-----------------------+---------+--------+
| fastlane-plugin-pgyer | 0.2.8   | pgyer  |
+-----------------------+---------+--------+

[21:57:10]: Make sure to commit your Gemfile, Gemfile.lock and Pluginfile to version control
Installing plugin dependencies...
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all
non-root users on this machine.
Successfully installed plugins

执行之后ios/fastlane生成如下文件

.
├── Appfile
├── Fastfile
└── Pluginfile

执行一下test

$ fastlane custom_lane
[] 🚀 
[19:27:00]: fastlane detected a Gemfile in the current directory
[19:27:00]: However, it seems like you didn't use `bundle exec`
[19:27:00]: To launch fastlane faster, please use
[19:27:00]: 
[19:27:00]: $ bundle exec fastlane custom_lane
[19:27:00]: 
[19:27:00]: Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile
[19:27:03]: ------------------------------
[19:27:03]: --- Step: default_platform ---
[19:27:03]: ------------------------------
[19:27:03]: Driving the lane 'ios custom_lane' 🚀

+---------------------------------------+
|           fastlane summary            |
+------+------------------+-------------+
| Step | Action           | Time (in s) |
+------+------------------+-------------+
| 1    | default_platform | 0           |
+------+------------------+-------------+

[19:27:03]: fastlane.tools finished successfully 🎉

最终目录

.
├── Appfile
├── Fastfile
├── Pluginfile
├── README.md
└── report.xml
文件作用
Appfile
Fastfile
Pluginfile
README.md
report.xml

安装前检查, 已安装可跳过

# 1. 查看是否安装了 Ruby
$ ruby -v
# 2. 检查是否安装了 Xcode 命令行工具
$ xcode-select -p
# bundler
$ bundler --version
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

官方文档
使用 Fastlane 上传 App 到蒲公英

fastlane官方文档

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值