[mtouch] Refactor how we detect and avoid broken frameworks when building for the simulator. (#9647)

* Use the existing information we have in the Frameworks class to determine
  whether a particular framework works in the simulator or not.
* Show a warning (MX5223) when we run into such a framework, but only if
  the linker is enabled (otherwise we'll often get warnings for API the developer
  doesn't use).
This commit is contained in:
Rolf Bjarne Kvinge 2020-09-17 13:31:29 +02:00 коммит произвёл GitHub
Родитель 3e3111d44b
Коммит 2071a13aa4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
19 изменённых файлов: 152 добавлений и 30 удалений

Просмотреть файл

@ -3140,6 +3140,30 @@ class Test {
}
}
[Test]
public void MT5223 ()
{
using (var mtouch = new MTouchTool ()) {
var code = @"
using System;
class Test {
static void Main ()
{
Console.WriteLine (typeof (IOSurface.IOSurface));
}
}
";
mtouch.NoFastSim = true;
mtouch.CreateTemporaryApp (code: code);
mtouch.CreateTemporaryCacheDirectory ();
mtouch.AssertExecute (MTouchAction.BuildSim, "build");
mtouch.AssertWarning ("MT", 5223, "Did not link with the framework 'IOSurface', because the current iOS SDK does not contain support for this framework in the simulator.");
mtouch.AssertWarningCount (1);
}
}
[Test]
public void TestCaseMismatchedAssemblyName ()
{

Просмотреть файл

@ -211,9 +211,6 @@ namespace Xamarin.Utils
Frameworks.ExceptWith (WeakFrameworks);
}
Frameworks?.RemoveWhere ((v) => global::Frameworks.IsFrameworkBroken (Application, v));
WeakFrameworks?.RemoveWhere ((v) => global::Frameworks.IsFrameworkBroken (Application, v));
// force_load libraries take precedence, so remove the libraries
// we need to force load from the list of libraries we just load.
if (LinkWithLibraries != null)

Просмотреть файл

@ -542,31 +542,4 @@ public class Frameworks : Dictionary <string, Framework>
}
}
#endif
#if MMP || MTOUCH
// This checks if a framework is unavailable due to bugs in Xcode (such as Apple forgetting to ship a library or headers for a framework, which seems to happen at least once a year).
public static bool IsFrameworkBroken (Application app, string framework)
{
if (app.IsSimulatorBuild) {
switch (framework) {
// Apple seems to have forgotten to ship the several libraries for the simulator in Xcode 12 betas (it's still available for device builds).
// https://github.com/xamarin/maccore/issues/2266
case "MediaSetup":
if (app.Platform != ApplePlatform.iOS)
return false;
break;
// framework missing on both iOS and tvOS simulators (but present for macOS)
case "MLCompute":
if (app.Platform == ApplePlatform.MacOSX)
return false;
break;
default:
return false;
}
Driver.Log (1, $"Can't use '{framework}' in the simulator because Apple didn't ship it with Xcode 12 {Driver.XcodeProductVersion}");
return true;
}
return false;
}
#endif
}

Просмотреть файл

@ -214,6 +214,16 @@ namespace Xamarin.Bundler {
continue;
}
break;
default:
if (App.IsSimulatorBuild && !Driver.IsFrameworkAvailableInSimulator (App, framework.Name)) {
if (App.LinkMode != LinkMode.None) {
ErrorHelper.Warning (5223, Errors.MX5223, framework.Name, App.PlatformName);
} else {
Driver.Log (3, Errors.MX5223, framework.Name, App.PlatformName);
}
continue;
}
break;
#endif
}

6
tools/mtouch/Errors.designer.cs сгенерированный
Просмотреть файл

@ -2243,6 +2243,12 @@ namespace Xamarin.Bundler {
}
}
internal static string MX5223 {
get {
return ResourceManager.GetString("MX5223", resourceCulture);
}
}
internal static string MT5301 {
get {
return ResourceManager.GetString("MT5301", resourceCulture);

Просмотреть файл

@ -2582,6 +2582,14 @@
<comment>
</comment>
</data>
<data name="MX5223" xml:space="preserve">
<value>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</value>
<comment>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</comment>
</data>
<data name="MT5301" xml:space="preserve">
<value>Missing 'strip' tool. Please install Xcode 'Command-Line Tools' component

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>

Просмотреть файл

@ -2986,6 +2986,14 @@
<note>
</note>
</trans-unit>
<trans-unit id="MX5223">
<source>Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</source>
<target state="new">Did not link with the framework '{0}', because the current {1} SDK does not contain support for this framework in the simulator.</target>
<note>This is a warning explaining why a native framework won't be referenced from the app when building for the simulator. The following are literal names and should not be translated: SDK
{0}: The name of the native framework
{1}: The current platform (will be either iOS, tvOS, watchOS or macOS).
</note>
</trans-unit>
<trans-unit id="MX5305">
<source>Missing 'lipo' tool. Please install Xcode 'Command-Line Tools' component
</source>