How to use the command 'fastlane' (with examples)

How to use the command 'fastlane' (with examples)

Fastlane is a command-line tool that allows developers to automate the build, deployment, and release process of mobile applications. It provides a simple and efficient way to perform common tasks and streamline the development workflow. The command fastlane is used to execute various actions provided by Fastlane.

Use case 1: Build and sign the iOS application in the current directory

Code:

fastlane run build_app

Motivation: The build_app action is used to build and sign an iOS application in the current directory. This is useful when you want to quickly generate a build for testing or distribution purposes.

Explanation:

  • fastlane: The command to run Fastlane actions.
  • run: The subcommand to execute a specific action.
  • build_app: The action that builds and signs the iOS application in the current directory.

Example output:

[11:46:53]: ------------------------------
[11:46:53]: --- Step: build_app ---
[11:46:53]: ------------------------------
[11:46:53]: $ xcodebuild clean build CODE_SIGN_IDENTITY="iPhone Developer" PROVISIONING_PROFILE="..."
[11:47:01]: ▸ ** BUILD SUCCEEDED **
[11:47:01]: ------------------------------
[11:47:01]: --- Step: build_app ---
[11:47:01]: ------------------------------
[11:47:01]: $ xcodebuild -exportArchive -archivePath ... -exportPath ... -exportOptionsPlist ...
[11:47:05]: ▸ ** EXPORT SUCCEEDED **
[11:47:05]: Build successful

Use case 2: Run pod install for the project in the current directory

Code:

fastlane run cocoapods

Motivation: The cocoapods action is used to run the pod install command for the project in the current directory. This is necessary when you want to install the required dependencies for the project.

Explanation:

  • fastlane: The command to run Fastlane actions.
  • run: The subcommand to execute a specific action.
  • cocoapods: The action that runs pod install for the project in the current directory.

Example output:

[11:51:34]: ------------------------------
[11:51:34]: --- Step: cocoapods ---
[11:51:34]: ------------------------------
[11:51:34]: $ pod install
[11:51:37]: Analyzing dependencies
[11:51:37]: Fetching podspec for `Alamofire` from `...`
[11:51:37]: Downloading dependencies
[11:51:37]: Installing Alamofire (5.2.0)
[11:51:38]: Generating Pods project
[11:51:38]: Integrating client project
[11:51:38]: Pod installation complete! There are 5 dependencies from the Podfile and 1 total pod installed.

Use case 3: Delete the derived data from Xcode

Code:

fastlane run clear_derived_data

Motivation: The clear_derived_data action is used to delete the derived data from Xcode. This is useful when you are experiencing build issues or want to free up disk space by removing unnecessary build artifacts.

Explanation:

  • fastlane: The command to run Fastlane actions.
  • run: The subcommand to execute a specific action.
  • clear_derived_data: The action that deletes the derived data from Xcode.

Example output:

[11:55:16]: ------------------------------
[11:55:16]: --- Step: clear_derived_data ---
[11:55:16]: ------------------------------
[11:55:16]: $ rm -rf ~/Library/Developer/Xcode/DerivedData/
[11:55:16]: Derived data cleared successfully

Use case 4: Remove the cache for pods

Code:

fastlane run clean_cocoapods_cache

Motivation: The clean_cocoapods_cache action is used to remove the cache for pods. This is necessary when you want to ensure that the latest versions of the dependencies are fetched, or when you suspect that the cache is causing issues.

Explanation:

  • fastlane: The command to run Fastlane actions.
  • run: The subcommand to execute a specific action.
  • clean_cocoapods_cache: The action that removes the cache for pods.

Example output:

[11:57:12]: ------------------------------
[11:57:12]: --- Step: clean_cocoapods_cache ---
[11:57:12]: ------------------------------
[11:57:12]: $ pod cache clean --all
[11:57:13]: Cleaning all Pod caches
[11:57:13]: Pods cache cleaned successfully

Conclusion:

The fastlane command is a powerful tool for automating the build and release process of mobile applications. By using its various actions, developers can save time and effort in executing common tasks. Whether it’s building and signing an iOS application, running pod install, deleting derived data, or clearing the cache for pods, Fastlane provides a convenient and consistent way to streamline the development workflow.

Related Posts

How to use the command 'tlmgr paper' (with examples)

How to use the command 'tlmgr paper' (with examples)

The command ’tlmgr paper’ is used to manage paper size options of a TeX Live installation.

Read More
How to use the command psalm (with examples)

How to use the command psalm (with examples)

Psalm is a static analysis tool for finding errors in PHP applications.

Read More
How to use the command 'rvm' (with examples)

How to use the command 'rvm' (with examples)

The ‘rvm’ command is a tool that allows users to easily install, manage, and work with multiple Ruby environments.

Read More