From 2e52dfdb3b4a1338dd8c51f1d4783d58f7b9cd97 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 25 Sep 2020 09:26:07 +0200 Subject: [PATCH] [tools] Unify information about CoreNFC in the Frameworks class, and fix selecting whether a framework should be linked weakly or not in dotnet-linker. This fixes a startup crash in the simulator with Xcode 12: Library not loaded: /usr/lib/libnfshared.dylib Referenced from: /Applications/Xcode_12.0.0-GMb.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreNFC.framework/CoreNFC Reason: no suitable image found. Did find: /usr/lib/libnfshared.dylib: mach-o, but not built for platform iOS-sim Ref: https://stackoverflow.com/q/63915728/183422 --- tools/common/Frameworks.cs | 9 +++++++-- tools/common/Target.cs | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs index d14d060cc5..63522d7a4d 100644 --- a/tools/common/Frameworks.cs +++ b/tools/common/Frameworks.cs @@ -330,7 +330,7 @@ public class Frameworks : Dictionary { "IntentsUI", "IntentsUI", 10 }, { "ARKit", "ARKit", 11 }, - { "CoreNFC", "CoreNFC", 11, true }, /* not always present, e.g. iPad w/iOS 12, so must be weak linked */ + { "CoreNFC", "CoreNFC", new Version (11, 0), NotAvailableInSimulator, true }, /* not always present, e.g. iPad w/iOS 12, so must be weak linked; doesn't work in the simulator in Xcode 12 (https://stackoverflow.com/q/63915728/183422) */ { "DeviceCheck", "DeviceCheck", new Version (11, 0), new Version (13, 0) }, { "IdentityLookup", "IdentityLookup", 11 }, { "IOSurface", "IOSurface", new Version (11, 0), NotAvailableInSimulator /* Not available in the simulator (the header is there, but broken) */ }, @@ -575,9 +575,14 @@ public class Frameworks : Dictionary if (app.IsSimulatorBuild && !framework.IsFrameworkAvailableInSimulator (app)) continue; - var add_to = app.DeploymentTarget >= framework.Version ? frameworks : weak_frameworks; + var weak_link = framework.AlwaysWeakLinked || app.DeploymentTarget < framework.Version; + var add_to = weak_link ? weak_frameworks : frameworks; add_to.Add (framework.Name); } + + // Make sure there are no duplicates between frameworks and weak frameworks. + // Keep the weak ones. + frameworks.ExceptWith (weak_frameworks); } static bool FilterFrameworks (Application app, Framework framework) diff --git a/tools/common/Target.cs b/tools/common/Target.cs index 7716a64a7e..032893700f 100644 --- a/tools/common/Target.cs +++ b/tools/common/Target.cs @@ -223,7 +223,6 @@ namespace Xamarin.Bundler { case "Metal": case "MetalKit": case "MetalPerformanceShaders": - case "CoreNFC": // some frameworks do not exists on simulators and will result in linker errors if we include them if (App.IsSimulatorBuild) continue;