Msbuild does not use default xcode version on hosted macOS agent to build Xamarin.Mac app
See original GitHub issueIssue 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
- Set xcode version
Expected Behavior
-
Build succeeds
-
Build logs show
_CoreCompileInterfaceDefinitions
uses selected Xcode version to build
Actual Behavior
-
Build fails
-
Build logs show
_CoreCompileInterfaceDefinitions
usesmacOS-12
agent default Xcode version14.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:
- Created 8 months ago
- Comments:6 (3 by maintainers)
The order is:
MD_APPLE_SDK_ROOT
environment variable.~/Library/Preferences/Xamarin/Settings.plist
file.xcode-select --print-path
/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).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 theSettings.plist
file does not exist but sometimes it does.I have tried a variety of different things, including suggestions from comments above:
~/Library/Preferences/Xamarin/Settings.plist
before or after settingxcode-select
version$MD_APPLE_SDK_ROOT
variable to/Applications/Xcode_14.0.1.app
(this variable appears to never be filled by default)/Applications/Xcode.app
symlink to point to/Applications/Xcode_14.0.1.app
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!