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)

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


Attachments

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

Note You need to log in before you can comment on or make changes to this bug.