skip to Main Content

When building my .NET 8 iOS MAUI app in an Azure DevOps build pipeline, it complains that I’m not using the latest Xcode.

        
ILLink : iOS error IL7000: An error occured while executing the custom linker steps. Please review the build log for more information. [/Users/runner/work/1/s/MyProject/MyProject.csproj::TargetFramework=net8.0-iOS]
/Users/builder/azdo/_work/1/s/xamarin-macios/src/build/dotnet/ios/generated-sources/UIKit/UIApplication.g.cs(95): error MT4162: The type 'UIKit.UISceneSessionActivationRequest' (used as a parameter in UIKit.UIApplication.ActivateSceneSession) is not available in iOS 16.4 (it was introduced in iOS 17.0). Please build with a newer iOS SDK (usually done by using the most recent version of Xcode). [/Users/runner/work/1/s/MyProject/MyProject.csproj::TargetFramework=net8.0-iOS]
        
ILLINK : error MT2362: The linker step 'Registrar' failed during processing: The type 'UIKit.UISceneSessionActivationRequest' (used as a parameter in UIKit.UIApplication.ActivateSceneSession) is not available in iOS 16.4 (it was introduced in iOS 17.0). Please build with a newer iOS SDK (usually done by using the most recent version of Xcode). [/Users/runner/work/1/s/MyProject/MyProject.csproj::TargetFramework=net8.0-iOS]       

I’ve set up my build pipeline to use macos-latest but Xcode 15 does not appear to be installed.

Note: I ran into this problem at work and have resolved it, so I’ll include my answer below.

2

Answers


  1. Chosen as BEST ANSWER

    As of December 2023, the macos-latest image is Mac OS 12. The list of build agents along with their image names is documented here

    Quick screen snip of the relevant image names here: enter image description here

    Step 1 - Use the actual latest image macos-13

    It's in preview as of right now, but it has latest versions of Xcode (15.0 and 15.0.1) installed.

    pool:
      vmImage: "macos-13"
    

    Step 2 - Select Xcode version

    I have some yaml in my build pipeline that lists out relevant information and selects the latest version of Xcode that I want to use.

      - 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
    

    Example output:

    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.231.0
    Author       : Microsoft Corporation
    Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
    ==============================================================================
    Generating script.
    ========================== Starting Command Output ===========================
    /bin/bash --noprofile --norc /Users/runner/work/_temp/bb313650-3256-4f80-b567-0ec926cb9c07.sh
    Mac OS version:
    13.6
    
    Installed Xcode versions:
    Xcode.app
    Xcode_14.1.0.app
    Xcode_14.1.app
    Xcode_14.2.0.app
    Xcode_14.2.app
    Xcode_14.3.1.app
    Xcode_14.3.app
    Xcode_15.0.1.app
    Xcode_15.0.app
    
    currently selected xcode:
    /Applications/Xcode_14.3.1.app/Contents/Developer
    
    selecting latest xcode...
    /Applications/Xcode_15.0.1.app/Contents/Developer
    Xcode 15.0.1
    Build version 15A507
    Finishing: Select Xcode Version
    

  2. This solution effectively ensures that the correct Xcode version 15.0.1 is used during the build process, allowing your .NET 8 iOS MAUI app to compile without encountering errors related to unavailable types from older iOS SDKs.

    trigger:
      branches:
        include:
          - develop
    
    variables:
        BuildConfiguration: Release
        DotNetVersion: 8.x
        iOSVersion: net8.0-ios
    
    pool:
      vmImage: "macos-13"
      demands: xcode
    
    steps:
    - task: PowerShell@2
      displayName: Select Xcode Version
      inputs:
        targetType: 'inline'
        script: |
          sudo xcode-select -s /Applications/Xcode_15.0.1.app
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search