dotnetco.de
Pipeline

Still using Xamarin Forms Azure Pipeline with macOS 14

Support for Xamarin ended on 01. May 2024. Nevertheless it’s still possible ot use Azure Pipeline to update your Xamarin Forms iOS or Android App. Here’s how:

Currently macOS12 is still Microsofts version for “macos-latest”. As macOS 12 only includes XCode 13.1 – 14.2, you’ll get the following error:

Asset validation failed SDK version issue. This app was built with the iOS 16.2 SDK. All iOS and iPadOS apps must be built with the iOS 17 SDK or later, included in Xcode 15 or later, in order to be uploaded to App Store Connect or submitted for distribution.

Xcode 15 is available in macOS 13 (Xcode 14.1 – 15.2) and macOS 14 (Xcode 14.3.1 – 16.0 (beta)). If you just change your pipeline from “macOS-latest” (or “macOS-12”) to “macOS-13” or “macOS-14” you will get the following error:

The nuget command failed with exit code(1) and error(/Users/runner/work/1/s/MyApp.Android/MyApp.Android.csproj(15446,11): error MSB4226: The imported project “/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets” was not found.

The following steps will help to compile your Xamarin Forms App even with macOS 14 and upload the apps to iOS AppStore and Google PlayStore. It’s a summary of Vinayak Nikams post on Microsofts Learn and C. Tewalts post on StackOverflow:

Install Xamarin manually

To install Xamarin manually in your image, add the following task to your azure pipeline script:

- task: Bash@3
  displayName: Install Xamarin
  inputs:
    targetType: 'inline'
    script: |
      brew install --cask xamarin-ios
      brew install --cask xamarin-android

Set runNuggetRestore to true

In your Xamarin iOS Task, runNuggetRestore is typically set to “false”. Now this needs to be changed to “true”:

- task: XamariniOS@2
  inputs:
    solutionFile: '**/*.sln'
    configuration: 'Release'
    clean: true
    packageApp: true
    runNugetRestore: true

Add further info output

While this step is not necessary, I found it quite helpful to have an additional output so I’ve added it right at the beginning of the steps-list in my pipeline:

- script: |
    echo Mac OS version:
    sw_vers -productVersion
    echo
    echo Installed Xcode versions:
    ls /Applications | grep 'Xcode'
    echo
    echo currently selected xcode:
    xcrun xcode-select --print-path
    echo
    echo selecting latest xcode...
    sudo xcode-select -s /Applications/Xcode_15.0.1.app
    xcrun xcode-select --print-path
    xcodebuild -version
  displayName: Select Xcode Version
Click here to show log output
##[section]Starting: Select Xcode Version
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.237.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /Users/runner/work/_temp/40d823ac-9362-47e7-97a7-0a159f73a7d7.sh
Mac OS version:
14.5
 
Installed Xcode versions:
Xcode.app
Xcode_14.3.1.app
Xcode_14.3.app
Xcode_15.0.1.app
Xcode_15.0.app
Xcode_15.1.0.app
Xcode_15.1.app
Xcode_15.2.0.app
Xcode_15.2.app
Xcode_15.3.0.app
Xcode_15.3.app
Xcode_15.4.0.app
Xcode_15.4.app
Xcode_16.0.0.app
Xcode_16.0.app
 
currently selected xcode:
/Applications/Xcode_15.0.1.app/Contents/Developer
 
selecting latest xcode...
/Applications/Xcode_15.0.1.app/Contents/Developer
Xcode 15.0.1
Build version 15A507
 
##[section]Finishing: Select Xcode Version

Summary of my azure pipeline

That’s it! So here is summary of my azure pipeline which still compiles my Xamarin Forms app with macOS 14. The necessary changes are highlighted, some steps are removed and marked by […]

trigger:
- master

pool:
  vmImage: 'macOS-14'
  demands: xcode

variables:
- group: build_variables

steps:
- script: |
    echo Mac OS version:
    sw_vers -productVersion
    echo
    echo Installed Xcode versions:
    ls /Applications | grep 'Xcode'
    echo
    echo currently selected xcode:
    xcrun xcode-select --print-path
    echo
    echo selecting latest xcode...
    sudo xcode-select -s /Applications/Xcode_15.0.1.app
    xcrun xcode-select --print-path
    xcodebuild -version
  displayName: Select Xcode Version

- task: Bash@3
  displayName: Install Xamarin
  inputs:
    targetType: 'inline'
    script: |
      brew install --cask xamarin-ios
      brew install --cask xamarin-android

- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '**/*.sln'

# Xamarin.iOS

- task: InstallAppleCertificate@2
[...]

- task: InstallAppleProvisioningProfile@1
[...]

- task: XamariniOS@2
  inputs:
    solutionFile: '**/*.sln'
    configuration: 'Release'
    clean: true
    packageApp: true
    runNugetRestore: true
    signingIdentity: '$(APPLE_CERTIFICATE_SIGNING_IDENTITY)'
    signingProvisioningProfileID: '$(APPLE_PROV_PROFILE_UUID)'

[...]

Leave a Comment