Bug 27855 - Native references are not copied to application bundle in Unified API application.
Summary: Native references are not copied to application bundle in Unified API applica...
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: MSBuild ()
Version: 1.10.0
Hardware: Macintosh Mac OS
: High normal
Target Milestone: master
Assignee: Chris Hamons
Depends on:
Reported: 2015-03-10 19:44 UTC by Ian Kozhurin
Modified: 2016-02-02 21:11 UTC (History)
3 users (show)

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

Sample project (43.28 KB, application/zip)
2015-03-10 19:44 UTC, Ian Kozhurin

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:

Description Ian Kozhurin 2015-03-10 19:44:37 UTC
Created attachment 10257 [details]
Sample project

When creating a simple Xamarin.Mac Unified API Application project which is referencing custom .dylib through Native References, build process gives a warning "MMPTASK: Warning MM2006: Native library '<libname>.dylib' was referenced but could not be found. (MM2006)" and the library is not copied over to application's bundle Contents/MonoBundle directory.

Steps to reproduce:

1. Create C# Unified API Xamarin.Mac Application project
2. Create a Xcode dynamic library project and build the library
3. Add dynamic library to Native References of Unified API project
4. Build Unified API project

Expected results: project builds and dynamic library is copied to Contents/MonoBundle directory.
Observed results: project builds with a warning: "MMPTASK: Warning MM2006: Native library '<libname>.dylib' was referenced but could not be found. (MM2006)", and dynamic library is not in the application's bundle.

Sample Unified API project with the Xcode dynamic library as a subproject is attached.
Comment 1 Ian Kozhurin 2015-03-10 22:33:22 UTC
Update to the original report:

Xamarin Studio
Version 5.8 (build 443)
Installation UUID: 1f7bbf53-bfaa-4aca-bf87-aee8fc8a09ba
	Mono 3.12.1 ((detached/b7764aa)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010000

Apple Developer Tools
Xcode 6.2 (6776)
Build 6C131e

Not Installed

Not Installed

Xamarin Android Player
Not Installed

Version: (Business Edition)

Build Information
Release ID: 508000443
Git revision: 73883239470cbe8e261c94d95f7c3d0452fd393b
Build date: 2015-03-10 07:22:51-04
Xamarin addins: a2ff7b617f09d9c45d8bbf3d010b5db0d7d36100

Operating System
Mac OS X 10.10.2
Comment 2 Abhishek 2015-03-11 08:01:02 UTC
I have tried this issue and able to reproduce the reported behavior  at my end.

Steps To Reproduce:
1. Download the sample test application from the above.
2. Run the application.Application deploy successfully on the system.
3. Go to error tab->warning tab.
4. Warning MM2006: Native library 'libsimpleDylib.dylib' was referenced but could not be found. (MM2006) will be shown on the warning tab.

Screencast: http://www.screencast.com/t/hhVVQrZALFzQ
IDE Log: https://gist.github.com/AkhileshKumar01/e1a8605db3404e5bc6ab

Build Info:

=== Xamarin Studio ===

Version 5.9 (build 171)
Installation UUID: 93e693b0-b53d-40f4-b29c-b61ff5cbe892
	Mono 4.0.0 ((detached/7f27bd7)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400000049

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.Android ===

Version: (Trial Edition)
Android SDK: /Users/xamarin23/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Version: Unknown version
Location: /Applications/Xamarin Android Player.app

=== Xamarin.iOS ===

Version: (Trial Edition)
Hash: 283a3f2
Branch: master
Build date: 2015-03-05 01:59:36-0500

=== Xamarin.Mac ===

Version: (Trial Edition)

=== Build Information ===

Release ID: 509000171
Git revision: a953c3342b9c8aab43bd5e67119d1a3439ddcc08
Build date: 2015-03-09 12:37:56-04
Xamarin addins: 76a6f0bdd3cecbf0960abefe1ce18661729ec693

=== Operating System ===

Mac OS X 10.10.0
Darwin 800BC.local 14.0.0 Darwin Kernel Version 14.0.0
    Fri Sep 19 00:26:44 PDT 2014
    root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
Comment 3 Chris Hamons 2015-03-16 13:54:03 UTC
I can confirm. We are not correctly handling that. We'll look at possibly getting that in 2.2, as 2.0 is already somewhat frozen.

Until we get this fixed, you can work around it by adding some post build custom commands.

In your exe project properties, go to custom commands and add:

cp lib/libsimpleDylib.dylib ${TargetDir}/UnifiedAPIWithDylib.app/Contents/MonoBundle/

with a working dir of ${SolutionDir}
Comment 4 Chris Hamons 2016-02-02 21:11:36 UTC
It turns out that https://developer.xamarin.com/samples/mac/UseMSBuildToCopyFilesToBundleExample/ is a better way to handle this than custom commands.

However, we now have a preview of bindings projects which should handle this for you: