Chapter 13 Strange Xcode warning

I get this strange warning from Xcode when I build the starter project.

warning build: Run script build phase ‘SwiftLint’ will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking “Based on dependency analysis” in the script phase.

It would be nice to “address this warning” but I cannot find where to do it. Any hints?

btw I upgraded to Xcode Version 14.0 on macOS 12.6.

Hi @sxbsxb, this is a new warning in Xcode 14.

We use SwiftLint to make the code style consistent.
Click the project name at the top of the Project navigator, then select your target.
Go to Build Phases, find the Run Script phase and click the disclosure arrow to expand it.

If you don’t want to use SwiftLint or don’t have in installed, click the trash icon at the top right of the phase to delete it.
If you do want to lint your code and want to stop this warning, uncheck the Based on dependency analysis button below the script.

Sarah

2 Likes

Thanks Sarah,

I unchecked the button and the warning has gone away. It wasn’t a big deal at all it turns out.

I have used Lint-like products before with other languages and they can be useful for readability. I don’t have swiftlint installed. I looked around and found several different sites where a version could be downloaded. I hesitate when there are so many. Your script is:

PATH=/opt/homebrew/bin:$PATH
if [ -f ~/com.raywenderlich.swiftlint.yml ]; then
  if which swiftlint >/dev/null; then
    swiftlint --no-cache --config ~/com.raywenderlich.swiftlint.yml
  fi
fi

I don’t have a /opt/homebrew directory. I have separately installed the Homebrew package in /usr/local but there is no swiftlint executable there. I don’t have any YAML files from raywenderlich either, so this script is never going to work for me.

Did you install SwiftLint?

brew install swiftlint

Check out this guide for installing and configuring SwiftLint:
https://github.com/raywenderlich/swift-style-guide/blob/main/SWIFTLINT.markdown

It’s aimed at people writing for raywenderlich but it’s applicable to anyone.

I also like to have it auto-correct as much as possible, so I add this before the current swiftlint line:

swiftlint --fix --no-cache --config ~/com.raywenderlich.swiftlint.yml

You can also work without the com.raywenderlich.swiftlint.yml rules by using this script which uses the defaults set up in Terminal:

PATH=/opt/homebrew/bin:$PATH
if which swiftlint >/dev/null; then
  swiftlint --fix --no-cache
  swiftlint --no-cache
fi
1 Like

This is driven by a new option in Xcode 14. The SwiftLint phase has been in all your RayWenderlich.com builds for a couple of years now.

To fix it, select the project (top level item) in the Project Navigator. Next, select Build Phases in the menu across the top. Twirl open the SwiftLint phase and UNCHECK ** “Based on dependency analysis”.

We’ll make sure this is fixed in all the book projects in a future update.

1 Like

Thanks for the replies. This is not a huge deal to me. I’m just the sort of person that likes to know why something happens.