Is there a way to change SwiftLint version in an Azure DevOps pipeline?

154 views Asked by At

I'm attempting to use SwiftLint version 0.50.1 in my Azure DevOps pipeline to check iOS builds. Currently, the latest SwiftLint version is 0.53.0. However, I encountered some issues while trying to switch to version 0.50.1.

Here's what I tried:

I started by uninstalling the current SwiftLint version using the command 'brew uninstall swiftlint'. Then, I attempted to install SwiftLint version 0.50.1 using 'brew install [email protected]'. However, I received an error message that mentioned 'No available formula with the name "[email protected]".' I also attempted to use 'brew switch swiftlint x.xx.x' to switch to version 0.50.1, but I encountered another error: 'Error: Unknown command: switch.'

I would appreciate some assistance in resolving these issues.

I started by uninstalling the current SwiftLint version using the command 'brew uninstall swiftlint'. Then, I attempted to install SwiftLint version 0.50.1 using 'brew install [email protected]'. However, I received an error message that mentioned 'No available formula with the name "[email protected]".' I also attempted to use 'brew switch swiftlint x.xx.x' to switch to version 0.50.1, but I encountered

1

There are 1 answers

0
Alvin Zhao - MSFT On

According to this document, CocoaPods is the recommended way to install a specific version of SwiftLint since it supports installing a pinned version rather than simply the latest (which is the case with Homebrew).

Taking my demo for example, I added the Podfile for my xcodeproj with contents below. enter image description here

platform :ios, '9.0'
use_frameworks!

target 'Github Xcode Demo' do
  pod 'SwiftLint', '0.50.1'
end

In the pipeline, I used CocoaPods@0 task to install [email protected]. Please pay attention to the path where the SwiftLint was downloaded.

steps:
- task: CocoaPods@0
  displayName: 'pod install'
  inputs:
    workingDirectory: 'Github Xcode Demo'

#[email protected] was retrieved under the path "$(build.Repository.LocalPath)/Github Xcode Demo/Pods/SwiftLint/"
- script: |
   "$(build.Repository.LocalPath)/Github Xcode Demo/Pods/SwiftLint/swiftlint" --version
  displayName: 'swiftlint version'

enter image description here

Hope the information would help.