"${Pods_Root}/Swiftlint/Swiftlint" Causes "Command Phasescriptexecution Failed with a Nonzero Exit Code" with Xcode 10

${PODS_ROOT}/SwiftLint/swiftlint causes Command PhaseScriptExecution failed with a nonzero exit code with Xcode 10

It seems to be an issue with the SwiftLint 0.26.0 script when using Xcode 10.0 beta 3 or newer.

Cause

It seems related to SwiftLint #2276, itself related to SourceKitten 0.21.0, fixed in SourceKitten 0.21.1 and SwiftLint Master.

Solution

Update to SwiftLint 0.27.0 or newer:

pod 'SwiftLint', '~> 0.27'

(and run pod update SwiftLint)

Illegal instruction: 4 ${PODS_ROOT}/SwiftLint/swiftlint

SwiftLint 0.18.x introduce a breaking change. They replace YamlSwift with Yams. Yams interprets YAML more strictly than YamlSwift, so if your .swiftlint.yml configurations previously worked with SwiftLint but didn't fully conform to the YAML 1.2 standard, you'll need to fix those validation errors.

In your (my) case, each mapping entry (denoted with a colon :) needs to be on its own line:

large_tuple:
warning: 3
type_name:
max_length:
warning: 42
variable_name:
min_length:
warning: 1

Note that a pull request was made to avoid crashing SwiftLint with this issue in the future: https://github.com/jpsim/Yams/pull/37

Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code

After trying all the solutions, I was missing is to enable this option in:

Targets -> Build Phases -> Embedded pods frameworks

In newer versions it may be listed as:

Targets -> Build Phases -> Bundle React Native code and images

  • Run script only when installing

Build Phases

Command PhaseScriptExecution failed with a nonzero exit code Xcode 11.3.1

This may happen when you click "Deny" on Keychain access dialog, after this, you can make Workaround1 and then try to restart your Mac.
Also not forget to use the latest version of swiftlint and pods, make pod update SwiftLint. After the restart, you can try to make:

$ sudo gem install cocoapods-deintegrate cocoapods-clean
$ pod deintegrate
$ pod clean

Extra command for swiftlint necessary after autocorrecting?

The first lines lists and corrects the code and also formats it (same as doing ctrl+i in Xcode). So to me it looks like the purpose of the second line is to again validate the code after it has been formatted.

Is it necessary? Well that is completely subjective isn't it?

Also not that --autocorrect is deprecated and have been replaced by --fix so the above command is now

swiftlint --fix --format


Related Topics



Leave a reply



Submit