Skip to content

Commit

Permalink
[mtouch] Display a specific error is a .framework binary is invalid. F…
Browse files Browse the repository at this point in the history
…ixes #5028 (#5031)

Instead of a generic `MT0000` caused by an exception reading the magic
numbers of the binary framework file.

This was caused be uncompressing an archive, with a symlink, into a
file system that does not support symlinks (on Windows).

ref: #5028
  • Loading branch information
spouliot committed Oct 23, 2018
1 parent b403da0 commit d2a9a57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 14 additions & 2 deletions docs/website/mtouch-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -915,15 +915,19 @@ 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.

### <a name="MT0136"/>MT0136: Cannot find the assembly {assembly} referenced from {assembly}.
<a name="MT0136"/>

### 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.

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.

### <a name="MT0137"/>MT0137: Cannot find the assembly {assembly}, referenced by an attribute in {assembly}.
<a name="MT0137"/>

### 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.
Expand All @@ -933,6 +937,14 @@ means that if the build otherwise succeeds, this warning can be ignored.

<!-- 0138-0139: used by mmp -->

<a name="MT0140"/>

### 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
Expand Down
8 changes: 7 additions & 1 deletion tools/mtouch/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

1 comment on commit d2a9a57

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jenkins job (on internal Jenkins) succeeded

Build succeeded
API Diff (from stable)
ℹ️ API Diff (from PR only) (please review changes)
Generator Diff (no change)
Test run succeeded

Please sign in to comment.