iOS控件

搭建iOS-Fastalne

2017-11-13  本文已影响85人  叫我公爵大人

一、环境配置

二、fastlane脚本编写

fastlane文件夹下在新建一个Fastfile

# Customise this file, documentation can be found here:
# https://github.com/fastlane/fastlane/tree/master/fastlane/docs
# All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md
# 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 "1.110.0"

default_platform :ios

platform :ios do

  before_all do
    ENV["SLACK_URL"] = "https://hooks.slack.com/services/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" # Webhook URL created in Slack
  end

  # 编译测试版本
  desc "Jenkins"
  lane :jenkins do |options|
    branch = 'master'

    ensure_git_branch(branch: branch)
    ensure_git_status_clean
    git_pull
    #increment_build_number
    # commit_version_bumpi
    # push_to_git_remote(remote:'origin', local_branch: branch, remote_branch: branch)
    # add_badge(shield: "v#{get_version_number}-#{get_build_number}-orange", no_badge: true)

    ipaFileName = “ test.ipa”;#”DailyBuild_v#{get_version_number}.#{get_build_number}.ipa";
    gym(
      workspace: './test.xcworkspace',
      scheme: 'test',
      clean: true,
      output_directory: ENV['SP_OUTPUT_DIRECTORY'],
      output_name: ipaFileName,
      configuration: 'Release',
      include_symbols: 'true',
      include_bitcode: 'false',
      archive_path: ENV['SP_ARCHIVE_PATH'],
      export_method: 'ad-hoc',
      codesigning_identity: 'XXXX(123456)',
      xcargs: "PROVISIONING_PROFILE_SPECIFIER='ad-hoc' DEVELOPMENT_TEAM='123456'",
      export_options: {
      provisioningProfiles: {"com.XXXX.XXXX" => "ad-hoc"},
      method:'ad-hoc',
      signingStyle:'manual'
   }
    )
    
    pgyer(
      api_key: "", 
      user_key: "",
      ipa: "#{ENV['SP_OUTPUT_DIRECTORY']}#{ipaFileName}")
  end

end

安装Plugin

到目前为止,大约有30个Plugin发布到了RubyGems下,我们可以通过如下命令来查找:

fastlane search_plugins [query]

详情可以看这里
AvailablePlugins

假设我们的项目中需要使用一个名叫version_from_last_tag,用于获取git的最近一个tag,那么我们在终端的项目目录下执行:

fastlane add_plugin version_from_last_tag

添加完成后,项目中会多出一个Gemfile,Gemfile.lock,fastlane/Pluginfile三个文件,其中这个Pluginfile实际上就是一个Gemfile,里面包含对于Plugin的引用,格式如下:

# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!

gem 'fastlane-plugin-version_from_last_tag'
gem 'fastlane-plugin-badge'
gem 'fastlane-plugin-pgyer'

而Pluginfile本身又被Gemfile引用,所以又印证上上文中的那句话:对Plugin的管理其实就是对RubyGem的管理。

此后的Plugin是实际用法和使用Action是一致的,所以就不在此赘述了。

三、Xcode工程配置

在Product —>Scheme —>Manage Schemes —>你的工程Scheme的Shared为YES

在.gitignore添加如下两句,防止report.xml和README.md自动生成每次commit带入

fastlane/report.xml

fastlane/README.md

参考:

升级Cocoapods 1.1.0

http://bundler.io/

使用 rbenv 安装和管理Ruby版本

使用rbenv安装和管理Ruby版本

Fastlane入门:安装篇

fastlane 之截图自动化(看着很蛋疼)

fastlane deliver 上传app到App Store

Fastlane自动化构建工具(完整解决测试和发布流程)

使用 Jenkins 实现持续集成 (iOS)

Fastlane实战(五):高级用法

fastlane docs

Fastlane实战(四):自动化测试篇

深入浅出 Fastlane 一看你就懂

上一篇 下一篇

猜你喜欢

热点阅读