The private repository has been created and optimized, but upgrading the private repository is still a hassle with many Git instructions, including submitting code, tagging, validating pod lib Lint, etc. But it is now possible to do this with an automated tool.

Private library reference juejin.cn/post/693645…

Fastlane

  • Fastlane is a collection of Ruby scripts

Using the concept of

  • Lane: channel
  • The Action mechanism
    • Action is the smallest unit of execution in the Fastlane automation process, embodied in the Fastfile script instructions
    • For example, cocoapods,git_add, etc., all of which correspond to a script written in Ruby
    • All current actions
      • fastlane actions
      • Describe the link docs. Fastlane. Tools/actions/Act…
      • Source link github.com/fastlane/fa…
    • Common action
      • Produce creates iOS apps that are available for iTunes Connect and Apple Developer Portal.
      • Cert automatically creates and maintains iOS code signing certificates.
      • Vision creates, updates, downloads, and fixes Provisioning Profiles.
      • Snapshot automatically localizes App screenshots to each device.
      • Frameit ADAPTS screen shots to the appropriate device screen size.
      • Gym creates and packages iOS apps.
      • Deliver Uploads screen shots, metadata, and apps to the App Store.
      • PEM automatically creates and updates the profile for Push notifications.

The installation

  • sudo gem install fastlane
  • Sudo gem install -n /usr/loac/bin fastlane
  • Brew Update, brew install Ruby

use

  • 1. Access the root directory of the project
  • Let’s say I CD this project into this directory

  • 2.fastlane init
    • Note that if you don’t have to do anything like upload, you can actually go into your project directory, create a folder, and inside that folder you can create “Use files”.
    • fastlane Fastfile
    • Because I’m just practicing my own private library so I’m just going to create an empty fastlane folder and go to that folder touch Fastfile and create a Fastfile file and open it with Xcode and edit it
  • 3. Describe different “channels” in Fastfile
    • In the navigation channel, use various actions to describe the automated process
    • Channel definition
      • Desc “Submit a private library”
      • lane :blib do |options|
      • Get transfer parameters
        • options[:xxx]
        • case
          • targetName = options[:project]
          • tagName = options[:tagName]
      • Implementation of various actions
        • branch
          • if
          • else
          • end
        • Print uI.message (“xxxx#{xx}”)
        • end

end

  • 4. Execute a “channel” in the project root directory

    • Fastlane Channel name parameter 1: Value 1 Parameter 2: value 2
      • Example :Fastlane ManagerLib Tag :0.1.0 Target :FastlaneTest
  • 5. Actual combat

    • 1. Create an index library for the remote private library
    • 2. Create a test code base

    • 3. Pod repo add XMGFMSpecs remote index warehouse address and then leave it alone
    • 4. CD to an empty folder pod lib create WLFBase Create an Example project
    • The previous steps refer to the article reference address at the beginning of the article.

    • The fastFile content can be viewed in the description connection if you do not understand the meaning
Desc 'ManagerLib uses this channel to quickly manage its own private libraries, Upgrade maintenance 'lane: ManagerLib do | options | tagName = options [: tag] targetName = options [: target] # concrete roadway above to perform actions which # 1. The pod install cocoapods( clean: true, podfile: "./Example/Podfile" ) # 2. git add . git_add(path: ".") # git commit -m 'xxx' git_commit(path: ".", message: # git push origin master push_to_git_remote # tagName ) # git push --tags push_git_tags # 4. pod spec lint pod_lib_lint(allow_warnings: true) # pod repo push XXXX xxx.podspec pod_push(path: "#{targetName}.podspec", repo: "XMGFMSpecs", allow_warnings: true) endCopy the code
  • Run the terminal fastlane ManagerLib Tag :0.1.0 Target :FastlaneTest
  • Of course your Podspecs files should be correct
  • Git remote Add Origin specifies the location of the git remote add Origin component repository

  • If your project is git clone, there should be no problem
  • And then it works fine

  • The index library is added successfully

  • Code submission successful

To optimize the

And then we kept managing and updating our own private library, and one day we fixed a little bug, Need a new tag 0.1.0 to upgrade to 0.1.1 after changing podspecs terminal $Fastlan ManagerLib tag:0.1.1 Target :FastlaneTest But I don’t want to upgrade successfully to 0.1.1 or 0.1.0 because the bug is so trivial.

  • Method 1
    • Git tag -d 0.0.1
    • Git push origin :0.0.1
    • Rerun script
  • Method 2
    • Write your Own Fastlane better
  • Error 0.1.0 tag already exists

To optimize

Desc 'ManagerLib uses this channel to quickly manage its own private libraries, Upgrade maintenance 'lane: ManagerLib do | options | tagName = options [: tag] targetName = options [: target] # concrete roadway above to perform actions which # 1. The pod install cocoapods( clean: true, podfile: "./Example/Podfile" ) # 2. git add . git_add(path: ".") # git commit -m 'xxx' git_commit(path: ".", message: Git push origin master push_to_git_remote Git_tag_exists (tag: git_tag_exists) TagName) UI. Message (" Tag :#{tagName} already exists, will be executed, 🚀") remove_tag(tag:tagName) end # 3. tagName ) # git push --tags push_git_tags # 4. pod spec lint pod_lib_lint(allow_warnings: true) # pod repo push XXXX xxx.podspec pod_push(path: "#{targetName}.podspec", repo: "XMGFMSpecs", allow_warnings: true) endCopy the code
  • Go to description link address lookup

  • Copy to the script

If git_tag_exists(tag: tagName) uI. message(" Tag :#{tagName} exists, delete action 🚀") remove_tag(tag:tagName) endMake a judgment call before you label

  • Remove_tag (tag:tagName) this action is used to remove local and remote tags
  • CD to the root directory
  • fastlane new_action
  • Name of your Action: remove_tag User-defined Name
  • One more such file is a Ruby script

  • Open the

remove_tag.rb

  • 1. Edit place to execute content

  • 2. Define the description

  • 3. Specific description

  • 4. Possible options where parameters are received

  • 5. Content output and returned values added without utilization can be deleted

  • 6. Author name and platform

Begin to write

  • The code at 4 is replaced by this
FastlaneCore: : ConfigItem. New (key: : tag, the description: "label name" need to be deleted, optional: false, is_string: True), FastlaneCore: : ConfigItem. New (key: : rL, the description: "whether need to delete the local label", optional: true, is_string: False, default_value: true), FastlaneCore: : ConfigItem. New (key: : rR, the description: "whether to need to delete the remote TAB," optional: true, is_string: false, default_value: true)Copy the code
  • Can not write if you can find the source link click to view

  • 1 modified code
    • Get the variables in params
    • Create an array to store instructions in an array
    • Execute all commands of the array
def self.run(params) tagName = params[:tag] isRemoveLocalTag = params[:rL] isRemoveRemoteTag = params[:rR] # 1. CMDS = [] # 2. Into the array, Git tag -d if isRemoveLocalTag CMDS << "git tag -d #{tagName} "end Git push origin :#{tagName}" end #3. Result = actions. sh(cmds.join('&')); return result endCopy the code
  • The complete code
module Fastlane module Actions module SharedValues REMOVE_TAG_CUSTOM_VALUE = :REMOVE_TAG_CUSTOM_VALUE end class RemoveTagAction < Action def self.run(params) tagName = params[:tag] isRemoveLocalTag = params[:rL] isRemoveRemoteTag = params[:rR] # 1. CMDS = [] # 2. Into the array, Git tag -d if isRemoveLocalTag CMDS << "git tag -d #{tagName} "end Git push origin :#{tagName}" end #3. Result = actions. sh(cmds.join('&')); Return result end def self.description "" end def self.details # Optional: # this is your chance to provide a more detailed description of this action "End def" self.available_options # Define all options your action supports. # Below a few examples [ FastlaneCore: : ConfigItem. New (key: : tag, the description: "label name" need to be deleted, optional: false, is_string: True), FastlaneCore: : ConfigItem. New (key: : rL, the description: "whether need to delete the local label", optional: true, is_string: False, default_value: true), FastlaneCore: : ConfigItem. New (key: : rR, the description: "whether to need to delete the remote TAB," optional: true, is_string: false, default_value: true) ] end def self.output end def self.return_value nil end def self.authors # So no one will ever forget your contribution to fastlane :) You are awesome btw! [" is_supported "] end def self.is_supported? (platform) # you can do things like # # true # # platform == :ios # # [:ios, :mac].include? (platform) # platform == :ios end end end endCopy the code

Verify that the instruction succeeded

  • The root directory of the CD
  • fastlane action remove_tag

successful

  • The terminal runs fastlane ManagerLib Tag :0.1.0 Target :FastlaneTest