To do a good job, we must first sharpen our tools. Rational use of tools to improve development efficiency not only helps us save time, the key is to help us get rid of some repetitive and inefficient work, focus on challenging and in-depth problems, and constantly improve ourselves. Here are some tips I use to improve productivity in daily development, and if you have a better way to improve productivity, please feel free to comment.

Code snippet

Xcode provides some snippets for us, but they are not comprehensive enough, but Xcode allows us to add snippets ourselves, which can greatly reduce development efficiency by adding common snippets. QMUI team of Tencent has opened an open source codesnippet library _Qmui-ios-Codesnippets. Integrating their codesnippet library can meet daily development needs and improve coding efficiency.

Xopen shortcut script

Custom XOpen shortcut script to quickly open projects in terminal

Detailed steps:

  1. Create an xopen file with the following contents:
#! /usr/bin/env ruby
require 'shellwords'

proj = Dir['*.xcworkspace'].first
proj = Dir['*.xcodeproj'].first unless proj

if proj
   puts "Opening  #{proj}"
   `open #{proj}`
else
  puts "No xcworkspace|xcproj file found"
end
Copy the code
  1. willxopenFiles in/usr/local/binRun the chmod 777 command to add read and write permissions

fastlane

Fastlane is a continuous integration toolset written in Ruby. Fastlane allows you to automate packaging, publishing, and more. Originally, I used the Xcodebuild command provided by Xcode to customize an XPublish script for packaging. For detailed configuration process, please refer to: IOS – Two auto-packaging scripts, but I abandoned them when I discovered fastlane, mainly because fastlane is more comprehensive and powerful. Fastlane’s integration process is relatively simple, and there are a lot of resources available online that can be used to refer to automated publishing for small teams – full automated publishing for Fastlane. Since Jenkins has been used for continuous integration in our project, FASTlane is not often used in daily life, mainly in the occasional separate test package or audit package. Here is a brief summary of my Fastlane configuration.

default_platform(:ios)

platform :ios do
  desc "send ipa to pgyer"
  lane :pgyer do
    To implement pod install, you need to configure cocoapods in Gemfile
    cocoapods(
      clean: true.podfile: "./Podfile"
    )
    # Package projects
    build_app(workspace: "****.xcworkspace".scheme: "* * * *".export_method: "ad-hoc".output_directory: "./fastlane/package".configuration: "Release")
    Install the dandelion plugin before uploading dandelion
    pgyer(api_key: "* * * * * * * *".user_key: "* * * * * * * * * *")
    Send message notification after upload to avoid forgetting
    notification(subtitle: "Finished Uploading".message: "upload success")
  end
end
Copy the code

A few caveats:

  1. Support for Cocoapods needs to be configured in Gemfile
Configure cocoapods and specify the version
gem 'cocoapods'.'1.7.1'
Copy the code
  1. Dandelion plug-in installation command

fastlane add_plugin pgyer

Gemfile after installation:

source "https://rubygems.org"

gem "fastlane"

Configure cocoapods and specify the version
gem 'cocoapods'.'1.7.1'

plugins_path = File.join(File.dirname(__FILE__), 'fastlane'.'Pluginfile')
eval_gemfile(plugins_path) ifFile.exist? (plugins_path)Copy the code

For more information about Fastlane’s features, see Actions in the official documentation.

Jenkins

Jenkins is an open source CI tool, using Jenkins can avoid some low-level mistakes through standardized operation process, developers from simple, tedious work released. There are also many Jenkins configuration tutorials on the Internet. The Jenkins Continuous integration tutorial is more detailed.