diff --git a/docs/website/mmp-errors.md b/docs/website/mmp-errors.md index 9441add907..c964e08bc4 100644 --- a/docs/website/mmp-errors.md +++ b/docs/website/mmp-errors.md @@ -146,6 +146,15 @@ For more details: https://developer.apple.com/news/?id=06282017a Consider updating your application and any dependencies to 64-bit. +### MM0135: Did not link system framework '{0}' (referenced by assembly '{1}') because it was introduced in {2} {3}, and we're using the {2} {4} SDK. + +To build your application, Xamarin.Mac must link against system libraries, some of which depend upon the SDK version specified in the error message. Since you are using an older version of the SDK, invocations to those APIs may fail at runtime. + +The recommended way to fix this error is to upgrade Xcode to get the needed SDK. If you have multiple versions of Xcode installed or want to use an Xcode in a non-default location, make sure to set the correct Xcode location in your IDE's preferences. + +Alternatively, enable the managed [linker](https://docs.microsoft.com/xamarin/mac/deploy-test/linker) to remove unused APIs, including (in most cases) the new ones which require the specified library. However, this will not work if your project requires APIs introduced in a newer SDK than the one your Xcode provides. + +As a last-straw solution, use an older version of Xamarin.Mac that does not require these new SDKs to be present during the build process. # MM1xxx: file copy / symlinks (project related) diff --git a/docs/website/mtouch-errors.md b/docs/website/mtouch-errors.md index f23a423e6b..ab6f423983 100644 --- a/docs/website/mtouch-errors.md +++ b/docs/website/mtouch-errors.md @@ -673,6 +673,16 @@ When using --recursive-directories, only 1 assembly should match +### MT0135: Did not link system framework '{0}' (referenced by assembly '{1}') because it was introduced in {2} {3}, and we're using the {2} {4} SDK. + +To build your application, Xamarin.iOS must link against system libraries, some of which depend upon the SDK version specified in the error message. Since you are using an older version of the SDK, invocations to those APIs may fail at runtime. + +The recommended way to fix this error is to upgrade Xcode to get the needed SDK. If you have multiple versions of Xcode installed or want to use an Xcode in a non-default location, make sure to set the correct Xcode location in your IDE's preferences. + +Alternatively, enable the managed [linker](https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/linker) to remove unused APIs, including (in most cases) the new ones which require the specified library. However, this will not work if your project requires APIs introduced in a newer SDK than the one your Xcode provides. + +As a last-straw solution, use an older version of Xamarin.iOS that does not require these new SDKs to be present during the build process. + # MT1xxx: Project related error messages ### MT10xx: Installer / mtouch diff --git a/tests/common/Configuration.cs b/tests/common/Configuration.cs index e797d31c27..c5c5a6d30b 100644 --- a/tests/common/Configuration.cs +++ b/tests/common/Configuration.cs @@ -29,6 +29,7 @@ namespace Xamarin.Tests public static string xcode5_root; public static string xcode6_root; public static string xcode72_root; + public static string xcode83_root; #if MONOMAC public static string mac_xcode_root; #endif @@ -208,6 +209,7 @@ namespace Xamarin.Tests xcode5_root = GetVariable ("XCODE5_DEVELOPER_ROOT", "/Applications/Xcode511.app/Contents/Developer"); xcode6_root = GetVariable ("XCODE6_DEVELOPER_ROOT", "/Applications/Xcode601.app/Contents/Developer"); xcode72_root = GetVariable ("XCODE72_DEVELOPER_ROOT", "/Applications/Xcode72.app/Contents/Developer"); + xcode83_root = GetVariable ("XCODE83_DEVELOPER_ROOT", "/Applications/Xcode83.app/Contents/Developer"); include_ios = !string.IsNullOrEmpty (GetVariable ("INCLUDE_IOS", "")); include_mac = !string.IsNullOrEmpty (GetVariable ("INCLUDE_MAC", "")); include_tvos = !string.IsNullOrEmpty (GetVariable ("INCLUDE_TVOS", "")); diff --git a/tests/mmptest/mmptest.csproj b/tests/mmptest/mmptest.csproj index 51da77dea1..b0241641c5 100644 --- a/tests/mmptest/mmptest.csproj +++ b/tests/mmptest/mmptest.csproj @@ -103,6 +103,7 @@ StringUtils.cs + diff --git a/tests/mmptest/src/WarningTests.cs b/tests/mmptest/src/WarningTests.cs new file mode 100644 index 0000000000..e1554f84cf --- /dev/null +++ b/tests/mmptest/src/WarningTests.cs @@ -0,0 +1,25 @@ +using System; +using System.IO; +using NUnit.Framework; + +namespace Xamarin.MMP.Tests +{ + [TestFixture] + public class WarningTests + { + [Test] + public void MM0135 () + { + var oldXcode = Xamarin.Tests.Configuration.xcode83_root; + + if (!Directory.Exists (oldXcode)) + Assert.Ignore ("This test requires Xcode 8.3 (or updated to a newer one that still warns MM0135)."); + + MMPTests.RunMMPTest (tmpDir => { + TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir); + var output = TI.TestUnifiedExecutable (test, environment: new string[] { "MD_APPLE_SDK_ROOT", Path.GetDirectoryName (Path.GetDirectoryName (oldXcode)) }); + output.Messages.AssertWarningPattern (135, $"Did not link system framework"); + }); + } + } +} diff --git a/tools/common/Assembly.cs b/tools/common/Assembly.cs index f5290415e0..86d9ab4ca1 100644 --- a/tools/common/Assembly.cs +++ b/tools/common/Assembly.cs @@ -328,6 +328,14 @@ namespace Xamarin.Bundler { return linkWith; } + void AddFramework (string file) + { + if (Driver.GetFrameworks (App).TryGetValue (file, out var framework) && framework.Version > App.SdkVersion) + ErrorHelper.Warning (135, "Did not link system framework '{0}' (referenced by assembly '{1}') because it was introduced in {2} {3}, and we're using the {2} {4} SDK.", file, FileName, App.PlatformName, framework.Version, App.SdkVersion); + else if (Frameworks.Add (file)) + Driver.Log (3, "Linking with the framework {0} because it's referenced by a module reference in {1}", file, FileName); + } + public void ComputeLinkerFlags () { foreach (var m in AssemblyDefinition.Modules) { @@ -382,8 +390,7 @@ namespace Xamarin.Bundler { #if MTOUCH if (!App.IsSimulatorBuild) { #endif - if (Frameworks.Add (file)) - Driver.Log (3, "Linking with the framework {0} because it's referenced by a module reference in {1}", file, FileName); + AddFramework (file); #if MTOUCH } #endif @@ -415,11 +422,7 @@ namespace Xamarin.Bundler { // detect frameworks int f = name.IndexOf (".framework/", StringComparison.Ordinal); if (f > 0) { - Framework framework; - if (Driver.GetFrameworks (App).TryGetValue (file, out framework) && framework.Version > App.SdkVersion) - Driver.Log (3, "Not linking with the framework {0} (referenced by a module reference in {1}) because it was introduced in {2} {3}, and we're using the {2} {4} SDK.", file, FileName, App.PlatformName, framework.Version, App.SdkVersion); - else if (Frameworks.Add (file)) - Driver.Log (3, "Linking with the framework {0} because it's referenced by a module reference in {1}", file, FileName); + AddFramework (file); } else { if (UnresolvedModuleReferences == null) UnresolvedModuleReferences = new HashSet ();