question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Msbuild does not use default xcode version on hosted macOS agent to build Xamarin.Mac app

See original GitHub issue

Issue Description

I have an issue with msbuild on my Azure DevOps hosted macOS agents.

As described in this Azure DevOps announcement, the way to select the xcode version should be done by performing:

sudo xcode-select -s "/Applications/Xcode_14.0.1.app"

In my pipeline there is an old Xamarin.Mac app that needs to be built with Xcode 14.0.1, otherwise the build will fail. The _CoreCompileInterfaceDefinitions of the msbuild output an ibtool call with arguments pointing to:

--sdk /Applications/Xcode_14.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk

I can validate that the Xcode default version is set properly by running the code below after xcode-select:

xcode-select -print-path
xcodebuild -version

I’ve also tried pointing the Xcode.app symlink to my desired Xcode version but this did not fix the issue.

sudo rm -rf /Applications/Xcode.app
ln -svf /Applications/Xcode_14.0.1.app /Applications/Xcode.app 

Steps to Reproduce

  • Create sample Xamarin.Mac application

  • Create and run build for hosted macOS-12 agent on Azure DevOps:

    • Set xcode version sudo xcode-select -s "/Applications/Xcode_14.0.1.app"
    • Call msbuild to build sample Xamarin.Mac

Expected Behavior

  • Build succeeds

  • Build logs show _CoreCompileInterfaceDefinitions uses selected Xcode version to build

Actual Behavior

  • Build fails

  • Build logs show _CoreCompileInterfaceDefinitions uses macOS-12 agent default Xcode version 14.2

Ask us questions

How can I force msbuild to use a specific Xcode version for building my Xamarin.Mac app?

On my local Mac I don’t have this issue (msbuild honors the selected Xcode version)

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
rolfbjarnecommented, Feb 8, 2023

The order is:

  1. Check the MD_APPLE_SDK_ROOT environment variable.
  2. Check the ~/Library/Preferences/Xamarin/Settings.plist file.
  3. Check xcode-select --print-path
  4. Use /Applications/Xcode.app

So I’m guessing you have a ~/Library/Preferences/Xamarin/Settings.plist file. The fix should be to remove that file (so that the build uses step 3. above instead).

0reactions
4or5treescommented, Feb 13, 2023

Hi guys, sorry for the late reply.

Thank you very much for your detailed responses!

Strangely, though, I have not been able to fix the build with them. Default xcode version is still always 14.2 in macOS-12 agents. It might be due to how the agents are configured, since in most builds the Settings.plist file does not exist but sometimes it does.

I have tried a variety of different things, including suggestions from comments above:

  • Deleting ~/Library/Preferences/Xamarin/Settings.plist before or after setting xcode-select version
  • Setting the $MD_APPLE_SDK_ROOT variable to /Applications/Xcode_14.0.1.app (this variable appears to never be filled by default)
  • Replacing existing /Applications/Xcode.app symlink to point to /Applications/Xcode_14.0.1.app
  • (and other things, I have lost track a bit)

I believe there might be a combination of fixes that I have not yet tried that will fix the issue. In case I find it, I will comment it here.

Additionally, we have unblocked our builds by manually selecting the macOS version. So the issue is not so urgent to fix for us at the moment.

So I think it should be OK to close this issue with this comment.

Thanks for your help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connection Troubleshooting for a Xamarin.iOS Build Host
This guide provides troubleshooting steps for issues that may be encountered using the new connection manager, including connectivity and ...
Read more >
How to build Xamarin.Mac app on Azure pipelines
For my project I'm building a macOS app with Xamarin.Mac and looking to be able to automate the build in Azure pipelines, but...
Read more >
Azure Devops Hosted Mac select Mono SDK 5.18.1 not ...
To manually select a Xamarin SDK version on the Hosted macOS agent, run this script with the SDK version you want to target ......
Read more >
How to fix CI build with Azure Hosted Agent for Xamarin ...
The fix is to use msbuild from VS 2022 for Mac. To do that you have to use mono executable as a runner...
Read more >
How do I fix code sign code 1 & unable to build chain?
Trying to build .iOS in Xamarin using Build/Iphone. Getting this error so it won't build.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found