如何在Azure DevOps MAUI构建管道中指定ios SDK版本

问题描述 投票:0回答:1

我有一个针对

net8.0-ios
的 MAUI 应用程序。在我的本地开发计算机(和远程连接的 Mac)上,我能够使用 Xcode 16 针对 iOS SDK 18 进行构建。在 Azure DevOps 中,我指定了
macos-14
作为代理图像,但它抱怨使用 iOS 17.5 而不是 18.0。

ILLINK : error MT2362: The linker step 'ClassHandleRewriter' failed during processing: One or more errors occurred. (The type 'MapKit.MKSelectionAccessory' (used as a return type in MapKit.MKMapView/_MKMapViewDelegate.GetSelectionAccessory) is not available in iOS 17.5 (it was introduced in iOS 18.0). Please build with a newer iOS SDK (usually done by using the most recent version of Xcode). [/Users/runner/work/1/s/App/App.csproj::TargetFramework=net8.0-ios]

其中重要的部分是:

...在 iOS 17.5 中不可用(它是在 iOS 18.0 中引入的)。请使用较新的 iOS SDK 构建(通常使用最新版本的 Xcode 完成)

如何告诉 DevOps 使用 iOS 18?我检查了 agent 规格,它有 iOS 18 和 Xcode 16。

Starting: Initialize job
Agent name: 'Hosted Agent'
Agent machine name: 'Mac-1727975076930'
Current agent version: '3.245.0'
Operating System
Runner Image
Image: macos-14
Version: 20240923.101
Included Software: https://github.com/actions/runner-images/blob/macos-14/20240923.101/images/macos/macos-14-Readme.md
Image Release: https://github.com/actions/runner-images/releases/tag/macos-14%2F20240923.101

这是我的管道 yaml 的 ios 阶段:

- stage: publish_ios
  dependsOn: []
  condition: and(succeeded(), in(variables['Environment'], 'QA', 'Production'))
  jobs:
  - job: BuildMAUIApps
    displayName: Build
    pool:
      vmImage: 'macos-14'
      demands:
      - MSBuild

    steps:

    # https://docs.microsoft.com/en-us/azure/devops/pipelines/apps/mobile/app-signing?view=azure-devops&tabs=apple-install-during-build#sign-your-apple-ios-macos-tvos-or-watchos-app
    # Setup Secret Pipeline Variable or Library Secrets Variable for iOS Certificate Password
    - task: InstallAppleCertificate@2
      inputs:
        certSecureFile: 'iOS-Distribution.p12'
        certPwd: '$(CertificatePassword)'
        keychain: 'temp'

    - task: InstallAppleProvisioningProfile@1
      inputs:
        provisioningProfileLocation: 'secureFiles'
        provProfileSecureFile: 'app.mobileprovision'

    - task: UseDotNet@2
      displayName: install dotnet
      inputs:
        packageType: 'sdk'
        version: $(dotnetVersion)

    - task: Bash@3
      displayName: install maui
      inputs:
        targetType: 'inline'
        script: |
          dotnet nuget locals all --clear
          dotnet workload install maui --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json --source https://api.nuget.org/v3/index.json
          dotnet workload install ios maui wasm-tools --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json --source https://api.nuget.org/v3/index.json

    - task: DotNetCoreCLI@2
      displayName: 'dotnet restore'
      inputs:
        command: 'restore'
        feedsToUse: 'config'
        nugetConfigPath: 'nuget.config'
        externalFeedCredentials: 'https://pkgs.dev.azure.com/org/_packaging/org/nuget/v3/index.json'

   # https://docs.microsoft.com/en-us/dotnet/maui/ios/deployment/overview
    - task: DotNetCoreCLI@2
      displayName: 'dotnet publish'
      inputs:
        command: 'publish'
        publishWebProjects: false
        projects: '**/App.csproj'
        arguments: '--configuration $(buildConfiguration) --framework net8.0-ios -p:CodesignProvision=$(APPLE_PROV_PROFILE_UUID) -p:ArchiveOnBuild=true -p:Version=$(Build.BuildNumber) -p:ApplicationDisplayVersion=$(Build.BuildNumber) -p:ApplicationVersion=$(Build.BuildId)'

    - task: CopyFiles@2
      inputs:
        Contents: |
          **/*.app
          **/*.ipa
        TargetFolder: '$(Build.ArtifactStagingDirectory)'

    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'ios'
        publishLocation: 'Container'
ios azure-devops azure-pipelines maui
1个回答
0
投票

您可以使用以下脚本将 Xcode 版本设置为 Xcode 16.0:

- script: |
    sudo xcode-select -switch /Applications/Xcode_16.app/Contents/Developer
    xcode-select -print-path
    xcodebuild -version
© www.soinside.com 2019 - 2024. All rights reserved.