Fastlane

优质
小牛编辑
128浏览
2023-12-01

Fastlane

一、Fastlane简介

Fastlane是一种配置iOS和Android自动化Beta部署和发布的最简单的方法之一。它可以简化一些乏味、单调、重复的工作,像截图、代码签名以及发布App。只需一条命令就可实现从 Xcode 项目到 编译\打包\构建\提交审核。

二、Fastlane安装

官方文档中提供了两种方式安装

  • gem安装:

    $ sudo gem install fastlane -NV

    ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.
    

    如果遇到权限问题,可尝试更换指令再次执行

    $ sudo gem install fastlane -n /usr/local/bin

    ...
    ...
    ...
    Done installing documentation for rouge, xcpretty,
    terminal-notifier, unicode-display_width, terminal-table, plist,
    public_suffix, addressable, multipart-post, word_wrap, tty-screen, tty-cursor,
    tty-spinner, babosa, colored, highline, commander-fastlane, excon, unf_ext, unf, domain_name, http-cookie, faraday, faraday-cookie_jar, fastimage, mini_magick,
    multi_xml, rubyzip, security, xcpretty-travis-formatter, dotenv, bundler, faraday_middleware, naturally, simctl, jwt, httpclient, multi_json, signet,
    os, memoist, googleauth, mime-types-data, mime-types, retriable,
    declarative-option, declarative, uber, representable, google-api-client,
    digest-crc, google-cloud-env, google-cloud-core, google-cloud-storage,
    emoji_regex, fastlane after 305 seconds
    56 gems installed
    

    成功完成.

  • Homebrew Cask安装

    $ brew cask install fastlane

安装辅助工具gym

  • sudo gem install -n /usr/local/bin gym

三、Fastlane使用

  • 设置 Fastlane

    将终端导航到项目目录并运行: $ fastlane init

    如果没有进入正确路径,会出现类似报错信息,重新定位到正确路径再次执行一次即可

      localhost:iOS_13_adapter_demo Shen$ fastlane init
      [✔] 
      [17:04:35]: Sending anonymous analytics information
      [17:04:35]: Learn more at https://docs.fastlane.tools/#metrics
      [17:04:35]: No personal or sensitive data is sent.
      [17:04:35]: You can disable this by adding `opt_out_usage` at the top of your Fastfile
      [✔] Looking for iOS and Android projects in current directory...
      [17:04:35]: Created new folder './fastlane'.
      [17:04:35]: It looks like there is no iOS project in the current directory, though we did find one in a sub-directory
      [17:04:35]: Please `cd` into the directory of the intended Xcode project you wish to use.
    
      [!] Please `cd` into the directory of the intended Xcode project you wish to use and run `fastlane init` again
    

    提示选择:

    ```bash localhost:iOS_13_Demo Shen$ fastlane init [✔]  [✔] Looking for iOS and Android projects in current directory... [17:09:24]: Created new folder './fastlane'. [17:09:24]: Detected an iOS/macOS project in the current directory: 'iOS_13_Demo.xcworkspace'

[17:09:24]: -----------------------------
[17:09:24]: --- Welcome to fastlane  ---
[17:09:24]: -----------------------------
[17:09:24]: fastlane can help you with all kinds of automation for your mobile app
[17:09:24]: We recommend automating one task first, and then gradually automating more over time
[17:09:24]: 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
?  
```

然后可能卡在$ updateing bundle

这时候先Control + Z取消,
然后打开项目路径下的Gemfile ,将里面的source跟换为https://gems.ruby-china.com保存, 然后再cd到你的项目目录下,执行bundle update,就可以看到bundle更新完成, 再执行fastlane init即可

TBD...