Bug 25762 - The mdtool build process does not automatically codesign .dylib files that it copies into the app bundle
Summary: The mdtool build process does not automatically codesign .dylib files that it...
Status: RESOLVED DUPLICATE of bug 23526
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.6.0
Hardware: PC Mac OS
: --- minor
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-06 20:48 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2015-01-07 10:29 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case (33.99 KB, application/zip)
2015-01-06 20:48 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 23526

Description Brendan Zagaeski (Xamarin Team, assistant) 2015-01-06 20:48:39 UTC
Created attachment 9261 [details]
Test case

The mdtool build process does not automatically codesign .dylib files that it copies into the app bundle. The new MSBuild tasks _do_ automatically codesign these files.

Admittedly this might be a known limitation of the old mdtool build process with no plans for a fix. If I'm not mistaken, .dylib usage in iOS apps has only been permitted on the App Store starting with iOS 8. So it's possible that updating the mdtool build process to handle this scenario might be unnecessary, especially considering that enabling the MSBuild build engine is an effective workaround (at least for the attached test project).  In short, feel free to mark the bug as RESOLVED INVALID (or similar) if appropriate.


Regression status: not a regression.


## Steps to reproduce

Build the "iOSFooAppClassic" project from the attached test case in Xamarin Studio on Mac and run it on a physical device.


## Test case

The test app is a simple template project with a few lines added to P/Invoke a native method from the `Foo.dylib` library.

The project has "MONO_LOG_LEVEL=debug" set under "Project Options -> Run -> General -> Environment Variables" to enable more verbose information from DllImport.


## Results

The app crashes because `Foo.dylib` was not signed during the build process.


### Error at run time

> DllImport error loading library 'Foo.dylib': 'dlopen(Foo.dylib, 9): no suitable image found.  Did find:
>	Foo.dylib: code signature invalid for 'Foo.dylib'
> '.

... and a little later:

> Unhandled managed exception: Foo.dylib (System.DllNotFoundException)


### Related "Build Output"

> Signing application
> codesign -v -f -s "123AB1A1A1234A12A123A123AA1A12A1234567A1"
>   "--resource-rules=/Users/macuser/Projects/iOSDylibSigning/iOSFooAppClassic/bin/iPhone/Debug/iOSFooAppClassic.app/ResourceRules.plist"
>   --entitlements "/Users/macuser/Projects/iOSDylibSigning/iOSFooAppClassic/bin/iPhone/Debug/iOSFooAppClassic.xcent"
>   "/Users/macuser/Projects/iOSDylibSigning/iOSFooAppClassic/bin/iPhone/Debug/iOSFooAppClassic.app"
> /Users/macuser/Projects/iOSDylibSigning/iOSFooAppClassic/bin/iPhone/Debug/iOSFooAppClassic.app: replacing existing signature
> /Users/macuser/Projects/iOSDylibSigning/iOSFooAppClassic/bin/iPhone/Debug/iOSFooAppClassic.app: signed bundle with Mach-O thin (armv7) [com.your-company.iOSFooAppClassic]


## Additional results / "workarounds"

- The "iOSFooApp" (Unified) project _does_ sign `Foo.dylib`, and the app runs successfully.

- Enabling "Project Options -> Build -> General -> Use MSBuild build engine" stops the problem for the "iOSFooAppClassic" project.

- Both the "iOSFooApp" project and the "iOSFooAppClassic" project build and run successfully when compiled via Visual Studio on Windows.

- Manually signing `Foo.dylib` with the same signing identity that Xamarin Studio uses for the .app bundle is sufficient to stop the problem.


## Version information

### Mac

Mac OS X 10.9.5

=== Xamarin Studio ===

Version 5.7 (build 660)
Installation UUID: 2c0ea975-8f73-4920-8414-3e9ae359fbf4
Runtime:
	Mono 3.12.0 ((detached/a813491)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312000068

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: 8.6.0.49 (Business Edition)
Hash: eb24bdc
Branch: 
Build date: 2015-01-06 14:27:58-0500

=== Build Information ===

Release ID: 507000660
Git revision: 6a74f9bdb90d9415b597064d815c9be38b401fee
Build date: 2014-12-18 00:38:00-05
Xamarin addins: 57be0f5e1433cb58b70ea9b52e9dc77ad791be40


### Windows

Microsoft Visual Studio Professional 2013
Version 12.0.30723.00 Update 3
Microsoft .NET Framework
Version 4.5.51641

Xamarin   3.9.235.0 (23e2325)
Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Xamarin.iOS   8.6.0.0 (cb9aa8428c4d41de5ee53797a6f05cacb43bc32c)
Comment 2 Rolf Bjarne Kvinge [MSFT] 2015-01-07 10:29:26 UTC

*** This bug has been marked as a duplicate of bug 23526 ***