Bug 59756 - Xamarin.MacDev.AppleSdkSettings.CheckChanged does nothing
Summary: Xamarin.MacDev.AppleSdkSettings.CheckChanged does nothing
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild (show other bugs)
Version: XI 10.12 (d15-3)
Hardware: PC Mac OS
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Jeffrey Stedfast
URL:
Depends on:
Blocks:
 
Reported: 2017-09-26 15:11 UTC by Aaron Bockover [MSFT]
Modified: 2017-10-06 08:41 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: No
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Aaron Bockover [MSFT] 2017-09-26 15:11:10 UTC
It is not possible to build different iOS or Mac projects within a single solution that require different versions of Xcode. This is a regression introduced by fixing https://bugzilla.xamarin.com/show_bug.cgi?id=46257

Within a single msbuild process (e.g. msbuild Foo.sln):

1. Solution builds Foo.MacApp.csproj against already-configured environment (say, /Applications/Xcode_8.3.3.app), all is well
2. Now we need to build Foo.iOS.csproj, but against a different Xcoee (say, /Applications/Xcode_9.app). The target sets the environment variable [MD_APPLE_SDK_ROOT=/Applications/Xcode_9.app] to happen before the regular build starts
3. When the normal iOS build process starts, DetectSdkLocationsTaskBase.Execute will be called, which immediately calls Xamarin.MacDev.AppleSdkSettings.CheckChanged, which _should_ notice that the paths differ since the last run (from (1)), and reload everything (by calling Xamarin.MacDev.AppleSdkSettings.Init). However, this code has been completely commented out with no indication as to why.

As a result, whatever Xcode is used _first_within_the_process_ will be cached forever.

I have implemented a ReloadXcodeSettings task that we are now using to work around this for now:
https://gist.github.com/abock/ebf88068ea85c1d97fb69f8e5552351c

  <PropertyGroup>
    <BuildDependsOn>
      _UseXcode9;
      $(BuildDependsOn);
      _ResetXcode;
    </BuildDependsOn>
  </PropertyGroup>
  <Target Name="_UseXcode9">
    <ReloadXcodeSettings XcodePath="/Applications/Xcode_9.0.app"/>
  </Target>
  <Target Name="_ResetXcode">
    <ReloadXcodeSettings/>
  </Target>
Comment 1 Jeffrey Stedfast 2017-09-26 17:40:41 UTC
PR: https://github.com/xamarin/xamarin-macios/pull/2781