Blog Layout

Multiline shell scripts in Azure Pipelines

Raphael Haase • Jan 20, 2022

Azure Pipelines can be a great tool for automating your iOS builds server-side and independent of a developers machine.


One of the cool features is that you can run Bash/ZSH scripts on the Mac which builds your iOS app before or after the primary build steps - and all that from the azure-pipelines.yml.

You can use this for example to update the build number in the Info.plist to your customized build number scheme or to do other modifications to the source code before the build process starts.

Add a script step to the yml

To do this, add a script step inside the azure-pipelines.yml wherever you want it, like this:

- script: |

    SOME_VAR="Production Build"

    echo "Building $SOME_VAR"


You can even add more parameters, e.g. a `displayName` to the script step like this:

- script: |

    SOME_VAR="Production Build"

    echo "Building $SOME_VAR"

  displayName: Print which flavor we are building

That displayName will then show up on the pane on the left in Azure Pipelines to describe what is happening whenever you look at how the pipeline is being executed. When you look at it after a couple of months, or if somebody else has to understand what is going on, that can greatly make you both your yml and the pipeline execution overall easier to understand. Particularly, if you script is mainly some regex magic :-)

Change the build number in an iOS build from the command line

You can for example change the build number like this prior to a build from such a command line script running on your macOS build machine in Azure Pipelines:

/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $BUILD_NUMBER" "$(Build.SourcesDirectory)/myapp/Info.plist

... assuming of course that you filed $BUILD_NUMBER with some meaningful value in your script before.

A robotic hand automates testing on Apple devices by touching them
By Raphael Haase 09 Feb, 2023
Automated testing is a must for any app on iOS. It not only saves time, it is crucial for ensuring consistently good user experience and data security of your apps.
By Raphael Haase 15 Dec, 2022
Automatisiertes Testen ist eine Technik, bei der vorher festgelegte Tests für eine mobile Anwendung automatisch ausgeführt werden. Dies kann dazu beitragen, die Qualität und Zuverlässigkeit einer App sicherzustellen, indem Fehler und andere Probleme erkannt werden, bevor die App veröffentlicht wird. Gerade auch, wenn es nur um ein Update gibt. Denn so genannte Regressionen, Fehler die wieder zurück kommen, können einer App ordentlich Probleme bereiten. Einige Vorteile von automatisierten Tests für iOS und Android sind:
Automatisiertes Testen auf iPhones durch Roboterhände
By Raphael Haase 01 Dec, 2022
In der Medizin- und Finanzbranche ist die Entwicklung von iOS-Apps, die zuverlässig und genau sind, unerlässlich. Automatisierte Tests können dabei helfen, diesen Prozess einfacher und effizienter zu gestalten. Werfen wir also einen Blick auf die Vorteile des automatisierten Testens bei der Entwicklung von iOS-Apps in der Medizin- oder Finanzbranche.
By Raphael Haase 20 Oct, 2022
Entwickelt man heute mobile Anwendungen für iOS oder Android, dann heisst es häufig man müsse unbedingt einem bestimmten Architektur-Pattern folgen wie MVVM oder VIPER. Sonst würde sofort die App schlecht werden. Nun ist es nicht verkehrt gewissen Mustern zu folgen, denn das macht es für andere Entwickler einfach den Code zu verstehen und man hilft natürlich auch sich selbst dabei, das Rad nicht neu zu erfinden. Das Problem ist aber, dass nicht alle Architektur-Muster gleichermassen geeignet sind. Am wichtigsten ist dabei wohl, dass viele Architektur-Muster für kleine Anwendungen mit 1-2 Entwicklern irgendetwas zwischen Overkill oder sogar Kontraproduktivität sind. 
Standup Paddling ist manchmal besser als ein Daily Standup
By Raphael Haase 06 Oct, 2022
Viele tun es, nicht alle lieben es: Das "Daily Standup". Heute geht es darum, warum ich dieses Ritual kritisch sehe und zu einem Umdenken rate.
A software developer leaving the team
By Raphael Haase 22 Sep, 2022
It's every CTO's worst nightmare: your developers are the lifeblood of your company. They manage our most valuable digital assets and without them, you can't launch or maintain any meaningful customer engagement plans. But what happens when one of these key members suddenly walks away from their post with little to no notice? Suddenly, you've got a critical hole in your product development team that needs to be filled – but fast! You must find a replacement quickly. But even then, there’s still the daunting task of ensuring continuity in launching and maintaining new products as well as existing applications already live on the market. In this blog post, we'll discuss ways to make sure your app stays up and running even if (or especially if!) a developer decides to move on swiftly leaving behind incomplete projects for whoever steps up next.
By Raphael Haase 07 Apr, 2022
If you get an Undefined Symbol error in test cases, here is the fix for the most likely simple issue.
Monterey landscape
By Raphael Haase 17 Feb, 2022
A quick recipe on how you can add a new path or folder to "the" command line path.
Pipelines
By Raphael Haase 20 Jan, 2022
Add multiline bash scripts in Azure Pipelines like this.
By Raphael Haase 06 Jan, 2022
How to setup the Jazzy documentation tool for Swift on an M1 / Apple Silicon Mac.
More Posts
Share by: