diff --git a/docs/website/mtouch-errors.md b/docs/website/mtouch-errors.md
index 28018c603d31..58e6da56748e 100644
--- a/docs/website/mtouch-errors.md
+++ b/docs/website/mtouch-errors.md
@@ -915,7 +915,9 @@ Alternatively, enable the managed [linker](https://docs.microsoft.com/en-us/xama
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.
-### MT0136: Cannot find the assembly {assembly} referenced from {assembly}.
+
+
+### MT0136: Cannot find the assembly {assembly} referenced from {assembly}.
This warning occurs when an assembly passed to mtouch contains a reference to
another assembly that can't be found.
@@ -923,7 +925,9 @@ another assembly that can't be found.
mtouch may in certain cases still find references at a later point, which
means that if the build otherwise succeeds, this warning can be ignored.
-### MT0137: Cannot find the assembly {assembly}, referenced by an attribute in {assembly}.
+
+
+### MT0137: Cannot find the assembly {assembly}, referenced by an attribute in {assembly}.
This warning occurs when an attribute contains a reference to another assembly
that can't be found.
@@ -933,6 +937,14 @@ means that if the build otherwise succeeds, this warning can be ignored.
+
+
+### MT0140: File '{framework_filename}' is not a valid framework.
+
+This error occurs when `mtouch` reads a binary in a `.framework` directory that is not a valid executable.
+
+It might be a broken file or a broken symlink (after decompressing an archive) to a valid file. The native framework should be removed and replaced with a valid one.
+
# MT1xxx: Project related error messages
### MT10xx: Installer / mtouch
diff --git a/tools/mtouch/Application.cs b/tools/mtouch/Application.cs
index 413fb0354423..bc1d8f4d1ba8 100644
--- a/tools/mtouch/Application.cs
+++ b/tools/mtouch/Application.cs
@@ -1667,7 +1667,13 @@ void BuildBundle ()
throw ErrorHelper.CreateError (99, $"Internal error: 'can't convert frameworks to frameworks: {files.First ()}'. Please file a bug report with a test case (https://github.com/xamarin/xamarin-macios/issues/new).");
var framework_src = files.First ();
var framework_filename = Path.Combine (framework_src, Path.GetFileNameWithoutExtension (framework_src));
- if (!MachO.IsDynamicFramework (framework_filename)) {
+ var dynamic = false;
+ try {
+ dynamic = MachO.IsDynamicFramework (framework_filename);
+ } catch (Exception e) {
+ throw ErrorHelper.CreateError (140, e, $"File '{framework_filename}' is not a valid framework.");
+ }
+ if (!dynamic) {
Driver.Log (1, "The framework {0} is a framework of static libraries, and will not be copied to the app.", framework_src);
} else {
var macho_file = Path.Combine (targetPath, Path.GetFileNameWithoutExtension (framework_src));