Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error MT0180: This version of Microsoft.iOS requires the iOS 16.1 SDK (shipped with Xcode 14.1) #6771

Closed
2 of 10 tasks
faceoffers28 opened this issue Dec 14, 2022 · 17 comments
Closed
2 of 10 tasks
Labels
bug report investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS

Comments

@faceoffers28
Copy link

Description

I'm having major issues after the latest .Net Maui updates. My iOS app will no longer build.

Here is a link to the initial GitHub issue I created. microsoft/azure-pipelines-tasks#17477

After forcing ASP.net to use 7.0.100 and Xamarin to use xamarin-sdk.sh 17_4_0_301, I'm still getting the error.

I even tried to force XCode to version 14.1 using the CmdLine@2 Task.

- task: CmdLine@2
  displayName: 'Set XCode Version'
  inputs:
    script: |      
      sudo xcode-select -s /Applications/Xcode_14.1.app

Does anyone know where this error is coming from? Is this coming from the Maui install? If so, how do I fix this? As-is, I can no longer build my iOS app.

Platforms affected

  • Azure DevOps
  • GitHub Actions - Standard Runners
  • GitHub Actions - Larger Runners

Runner images affected

  • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04
  • macOS 11
  • macOS 12
  • Windows Server 2019
  • Windows Server 2022

Image version and build link

Current image version: '20221204.1'

Is it regression?

Current image version: '20221204.1'

Expected behavior

I would expect for the app to build.

Actual behavior

The app no longer builds.

Repro steps

Try to build a .Net Maui iOS app targeting iOS 16 with the Microsoft Visual Studio Enterprise 2022 (64-bit) - Current
Version 17.4.3 SDKs using the macos-12 image.

@faceoffers28
Copy link
Author

faceoffers28 commented Dec 14, 2022

I think the problem lies with the latest version of .Net Maui.

I can see that the Maui install Task is installing this version of microsoft.net.sdk.ios.

Installing workload manifest microsoft.net.sdk.ios version 16.1.1481

This is the version used in my last successful build.

Installing workload manifest microsoft.net.sdk.ios version 16.0.1478

@jdunaway
Copy link

jdunaway commented Dec 15, 2022

I'm facing the same issue. Azure Dev Ops pipeline builds are failing that were working earlier this week due to this same error. So I think this is a .Net Maui issue.

@igorboskovic3
Copy link
Contributor

Thank you @faceoffers28 , we will check it, can you provide minimal repro steps?

@igorboskovic3 igorboskovic3 added OS: macOS investigate Collect additional information, like space on disk, other tool incompatibilities etc. and removed needs triage labels Dec 15, 2022
@gabsamples6
Copy link

Hi @igorboskovic3
Since upgrading to latest version of visual studio any maui app launched as iOS we get an error

  1. Launch Visual studio (Microsoft Visual Studio Enterprise 2022 (64-bit) - Current Version 17.4.3)
  2. Create a Maui App
  3. Pair to a mac (optional)
  4. Build the app

image

@berhir
Copy link

berhir commented Dec 15, 2022

@gabsamples6 I don't want to ask the obvious question, but you didn't say what XCode version you are using. Did you update to XCode 14.1?

Anyway, this issue is about building on an Azure DevOps hosted agent.

@berhir
Copy link

berhir commented Dec 15, 2022

@igorboskovic3 the iOS build with the latest MAUI version doesn't work for us too.
This is how I select the correct XCode version:

  - task: Bash@3
    displayName: Select xcode version
    inputs:
      targetType: 'inline'
      script: |
        sudo xcode-select -s "/Applications/Xcode_14.1.app"

The build works fine, but when the "Optimizing assemblies" stuff starts, I get this warning:
ILLINK : warning MT0079: The recommended Xcode version for Microsoft.iOS 16.1.1481 is Xcode 14.1 or later. The current Xcode version (found in /Applications/Xcode_14.0.1.app/Contents/Developer) is 14.0.1. [/Users/runner/work/1/s/src/MyProj.csproj::TargetFramework=net7.0-ios]

After some time, it fails with this error:

xcodebuild: error: SDK "/Applications/Xcode_14.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" cannot be located.
xcrun: error: sh -c '/Applications/Xcode_14.1.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode_14.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -find dsymutil 2> /dev/null' failed with exit code 16384: (null) (errno=Invalid argument)
xcrun: error: unable to find utility "dsymutil", not a developer tool or in PATH

In the error message it looks like it's using XCode 14.1.

@faceoffers28
Copy link
Author

faceoffers28 commented Dec 15, 2022

Starting with the version of VIsual Studio before this last release, I noticed that I couldn't select the version of iOS to use once I selected Asp.net 7.

You can see the problem here. It still hasn't been fixed. I assume VS can't determine what version of .Net Maui is installed therefore it can't suggest the correct version of iOS to use. It appears that Microsoft has made the initial release of .Net Maui dependent on iOS 16.0. It also appears that Microsoft has made latest release of .Net Maui dependent on iOS 16.1.

image

I can manually edit the csproj and set iOS to 16.1, as shown below. When I try to Build, using Visual Studio, I get all kinds of errors.

<TargetFrameworks>net7.0-ios16.1;net7.0-android33.0</TargetFrameworks>

Bottom line, this is really messed up! I'm going to try to work through the 15 errors that were just introduced when I tried to upgrade to iOS 16.1. In the meantime, I'm getting closer to recreating the last successful .Net Maui Build using Azure DevOps. I'll keep experimenting with both seeing as I need to get this app built and uploaded to the App Store before the end of year.

@faceoffers28
Copy link
Author

faceoffers28 commented Dec 15, 2022

I changed up my Pipeline to try and recreate the last .Net Maui Build that worked. I'm trying to recreate the initial Asp.net 7.0 .Net Maui environment in Azure DevOps.

- task: UseDotNet@2
  displayName: .NET Version
  inputs:
    packageType: 'sdk'
    version: '7.0.100'

- task: CmdLine@2
  displayName: 'Install Maui'
  inputs:
    script: 'dotnet workload install maui --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/7.0.1xx.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json --source https://api.nuget.org/v3/index.json'

Here is the error I'm getting in the DotNetCoreCLI@2 publish Task.

============================================================================== 
Task : .NET Core 
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command 
Version : 2.210.0 
Author : Microsoft Corporation 
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli 
============================================================================== 
Info: .NET Core SDK/runtime 2.2 and 3.0 are now End of Life(EOL) and have been removed from all hosted agents. If you're using these SDK/runtimes on hosted agents, kindly upgrade to newer versions which are not EOL, or else use UseDotNet task to install the required version. 
/Users/runner/hostedtoolcache/dotnet/dotnet publish /Users/runner/work/1/s/MyAppName.sln -f:net7.0-ios16.0 -c:Debug /p:ArchiveOnBuild=true /p:EnableAssemblyILStripping=false --runtime ios-arm64 --self-contained 
MSBuild version 17.4.0+18d5aef85 for .NET 
Determining projects to restore... 
Restored /Users/runner/work/1/s/MyAppName.csproj (in 30.99 sec). 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): warning : MAUI0000 [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): error MAUI0000: System.IO.IOException: The process cannot access the file '/Users/runner/work/1/s/obj/Debug/net7.0-ios16.0/ios-arm64/resizetizer/r/Resources/success.png' because it is being used by another process. [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): error MAUI0000: at Microsoft.Win32.SafeHandles.SafeFileHandle.Init(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Int64& fileLength, UnixFileMode& filePermissions) [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): error MAUI0000: at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Func`4 createOpenException) [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): error MAUI0000: at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): error MAUI0000: at Microsoft.Maui.Resizetizer.Resizer.CopyFile(DpiPath dpi, String inputsFile) in D:\a\_work\1\s\src\SingleProject\Resizetizer\src\Resizer.cs:line 51 [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): error MAUI0000: at Microsoft.Maui.Resizetizer.ResizetizeImages.ProcessImageCopy(ResizeImageInfo img, DpiPath originalScaleDpi, ConcurrentBag`1 resizedImages) in D:\a\_work\1\s\src\SingleProject\Resizetizer\src\ResizetizeImages.cs:line 201 [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): error MAUI0000: at Microsoft.Maui.Resizetizer.ResizetizeImages.<>c__DisplayClass26_0.<ExecuteAsync>b__0(ResizeImageInfo img) in D:\a\_work\1\s\src\SingleProject\Resizetizer\src\ResizetizeImages.cs:line 72 [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.Maui.Resizetizer.Sdk/7.0.49/targets/Microsoft.Maui.Resizetizer.targets(531,9): error MAUI0000: at Microsoft.Maui.Resizetizer.AsyncTaskExtensions.<>c__DisplayClass0_0`1.<ParallelForEach>b__0(TSource s) in D:\a\_work\1\s\src\SingleProject\Resizetizer\src\AsyncTaskExtensions.cs:line 21 [/Users/runner/work/1/s/MyAppName.csproj::TargetFramework=net7.0-ios16.0] 
Workload updates are available. Run `dotnet workload list` for more information. 
##[error]Error: The process '/Users/runner/hostedtoolcache/dotnet/dotnet' failed with exit code 1 
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build 
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting 
##[error]Dotnet command failed with non-zero exit code on the following projects : /Users/runner/work/1/s/MyAppName.sln 
Finishing: dotnet publish (Debug) 


@faceoffers28
Copy link
Author

faceoffers28 commented Dec 15, 2022

I was finally able to get my iOS app to Build using what I think is the configuration for the first .Net Maui release. This does not fix the current problem, but at least I can Build my app again.

Here is part of the script that I used.

Tell the Pipeline to use Asp.net 7.0.100.

- task: UseDotNet@2
  displayName: .NET Version
  inputs:
    packageType: 'sdk'
    version: '7.0.100'

Tell the Pipeline to use .Net Maui 7.0.1xx.

https://github.com/dotnet/maui/tree/release/7.0.1xx

This is where 7.0.1xx was upgraded to microsoft.net.sdk.ios version 16.0.1478.

dotnet/maui@e5c8224

- task: CmdLine@2
  displayName: 'Install Maui'
  inputs:
    script: 'dotnet workload install maui --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/7.0.1xx.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json --source https://api.nuget.org/v3/index.json'

Tell the Pipeline to use xamarin-sdk.sh 17_4_0_301. This was the last version of the Xamarin SDK before the upgrade to 17.4.3 .

- task: CmdLine@2
  displayName: 'Set Xamarin SDK'
  inputs:
    script: |      
      /bin/bash -c "sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 17_4_0_301"  

@trevortirrell
Copy link

This worked. Thank you! @faceoffers28

@mattjohnsonpint
Copy link

mattjohnsonpint commented Dec 16, 2022

I was able to get the latest working on GitHub Actions with the following:

    - name: Set XCode Version
      if: runner.os == 'macOS'
      shell: bash
      run: |
        sudo xcode-select -s "/Applications/Xcode_14.1.app"
        echo "MD_APPLE_SDK_ROOT=/Applications/Xcode_14.1.app" >> $GITHUB_ENV

The MD_APPLE_SDK_ROOT environment variable sets the Xcode path used by Xamarin.

I thought it was supposed to use the result of xcode-select -p, but apparently not.

CC: @rolfbjarne

@rolfbjarne
Copy link

@mattjohnsonpint we check the following, in order:

  1. The MD_APPLE_SDK_ROOT environment variable.
  2. What's configured in ~/Library/Preferences/Xamarin/Settings.plist
  3. xcode-select -p

@berhir
Copy link

berhir commented Dec 16, 2022

Thank you @mattjohnsonpint, I can confirm that your solution works also with Azure Pipelines.
I can finally build our iOS app with the latest MAUI version. This is the Azure Pipelines task to set the XCode version:

  - task: Bash@3
    displayName: Set XCode Version
    inputs:
      targetType: 'inline'
      script: |
        sudo xcode-select -s "/Applications/Xcode_14.1.app"
        echo "##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]/Applications/Xcode_14.1.app"

@mattjohnsonpint
Copy link

mattjohnsonpint commented Dec 16, 2022

we check the following, in order:

  1. The MD_APPLE_SDK_ROOT environment variable.
  2. What's configured in ~/Library/Preferences/Xamarin/Settings.plist
  3. xcode-select -p

That makes sense. Just tested and the default currently on the macos-12 GHA runner image is MD_APPLE_SDK_ROOT not set, but both the ~/Library/Preferences/Xamarin/Settings.plist and xcode-select -p showing 14.0.1.

(On the macos-11 image, it's similar, but both are set to 13.2.1.)

Thus, using xcode-select -s alone is insufficient; one also needs to either set the environment variable or update the plist.

@mikhailkoliada
Copy link
Contributor

Hello! Given all the above I am going to close the issue. Unfortunately, unlike GH actions, AzDo does not have a nice way (a task) to switch between xcode versions :(, nothing can be done on our side.

@Eilon
Copy link

Eilon commented May 12, 2023

The advice here worked for me. I use GitHub Actions to build a project based on .NET MAUI 7.x and has Windows and macOS builds to build all 4 main MAUI platforms (Windows, Android, iOS, macOS).

Here's what I ended up with in my YML file:

https://github.com/Eilon/HybridWebView/blob/4fcf89408bbfb38caa7edabf877f541cb8aaabcf/.github/workflows/_build.yml#L27-L41

@mattjohnsonpint
Copy link

@Eilon - Hi! 👋 I'm in a similar setup as you.

No need to go back to Xcode 14.1 at this point. You can use 14.2, and only a minimal rollback file is needed. See xamarin/xamarin-macios#17561 (comment)

It's only Xcode 14.3 that we can't use in Github Actions yet (unless you want to try the macos-13 runner, currently in beta).

The only real problem today is that the latest iOS and MacCatalyst dotnet workloads require Xcode 14.3, so don't work on the macos-12 runner. (It would be better if somehow we could have compatible workloads installed by default, without having to use rollback files.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: macOS
Projects
None yet
Development

No branches or pull requests

10 participants