Skip to main content

SwiftLint

SwiftLint checks the source code for programmatic as well as stylistic errors. This is helpful in identifying some common and uncommon mistakes that are made during coding. This step installs SwiftLint and runs SwiftLint with the given options.

Prerequisites

Remember, SwiftLint must be used after the following steps in order to work as expected.

Prerequisite Workflow StepDescription
Git CloneThe repo needs to be cloned in order to start the CocoaPods installation process. After the clone, CocoaPods will be installed, and then SwiftLint will be run. After this step works, the variable AC_REPOSITORY_DIR will be created. This variable is the input variable for CocoaPods and SwiftLint.
Cocoapods InstallThis step will install the dependencies in the project before SwiftLint can run.
warning

If you are using CocoaPods, note that this step is dependent on the CocoaPods Install step. Otherwise, the SwiftLint component will fail, and the pipeline will break.

caution

If you are using Swift Package Manager (SPM), do not use this step. SPM packages will be compiled in other steps that work with Xcode, such as Xcodebuild for Devices.

If you have SPM in your project and you are using the SwiftLint component in your workflow, the Linter component will give an error because it cannot find the required dependencies.

Input Variables

You can also customize your SwiftLint step with the options in the component. You can find all the detailed descriptions for all variables in the table below.

Variable NameDescriptionStatus
$AC_REPOSITORY_DIRSpecifies the cloned repository directory.Required
$AC_LINT_PATHThis is the path of SwiftLint dependency. It comes from the Xcode Build Phase section.Optional
$AC_LINT_RANGEWith the Range option, you can run SwiftLint on your entire project or only on changes in PR. Default is all.Optional
$AC_LINT_CONFIGSpecifies the linting configuration file. For example: /.swiftlint.ymlOptional
$AC_LINT_REPORTERYou can change the report type with the Reporter Format option. This option supports extensions such as html, json, junit, etc. The default is Xcode.Optional
$AC_LINT_STRICTIf there is a failure in the running lint, you can break the pipeline with the Strict option. The default value is NO.Optional
AC_LINT_QUIETIf you want the logs to be simpler, you can make the report file simpler with the Quiet Mode feature.Optional

Output Variables

Variable NameDescription
$AC_LINT_OUTPUT_PATHThe path of the SwfitLint results output file. After SwiftLint runs, all results will be written in a .txt file. It can be found in the download artifacts.

To access the source code of this component, please use the following link:

Preview of GitHub - appcircleio/appcircle-swiftlint-component