6

I have a run script build phase I have added to an Xcode project.

I want to be able to toggle this run script on when I want it to run and off when I don't.

Is this possible in Xcode and if so how can it be done?

3
  • What does it do? How do you want to control the on/off status? Can you add it as a different target? Commented Nov 20, 2014 at 20:18
  • You could move the script to a file, have the run script phase be a single line to execute the script in the file. Then, just comment out the single line when you don't want it to run? Commented Nov 20, 2014 at 22:16
  • I decided to add it as a different target. I set up an Aggregate target and added the run script there so that it would only run when building that target. Thanks! Commented Nov 21, 2014 at 14:13

1 Answer 1

2

I used to write exit in the first line to toggle off the script and #exit to toggle on, just like this:

Turn off a script e.g. SwiftLint:

exit
if which swiftlint >/dev/null; then
  swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

Turn on:

#exit
if which swiftlint >/dev/null; then
  swiftlint
else
  echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

You just have to modify 1 character whether exit is commented out or not.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.