Bug 26318 - Incremental Build setting causes app crash on launch: "Library not loaded ... *.exe.dylib"
Summary: Incremental Build setting causes app crash on launch: "Library not loaded ......
Status: VERIFIED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: iOS ()
Version: 3.9
Hardware: PC Windows
: --- normal
Target Milestone: 4.1.0 (C7)
Assignee: Brendan Zagaeski (Xamarin Team, assistant)
URL:
Depends on:
Blocks:
 
Reported: 2015-01-22 23:00 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-05-18 19:20 UTC (History)
10 users (show)

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


Attachments
Test case (7.85 KB, application/zip)
2015-01-22 23:00 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Diagnostic build logs (31.85 KB, application/zip)
2015-01-22 23:01 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 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:
VERIFIED FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2015-01-22 23:00:57 UTC
Created attachment 9459 [details]
Test case

Incremental Build setting causes app crash on launch: "Library not loaded ... *.exe.dylib"

This is the same problem described in bug 23526, but that bug was for Xamarin Studio. The incremental build process now works correctly for iOS 8 devices in Xamarin Studio but still fails in Visual Studio.


Regression status: the behavior is the same on 3.8.150, 3.9.236, and 3.9.274 (74260cb).


## Workaround

Disable "iOS Build -> General -> Debugging options -> Enable incremental builds".


## Steps to reproduce

(If you prefer, instead of steps 1-3 you can use the attached test case.)

1. Create a new iOS app, using either the Classic or Unified API.

2. Set the Unified Devices menu to select a hardware device connected to the Mac build host.

3. Enable "iOS Build -> General -> Debugging options -> Enable incremental builds" and save the project properties.

4. Attempt to build and run the project on an iOS 8 device.



## Results: the build process does not sign the `.dylib` files as required

(See also the `codesign` commands in the verbose build logs.)

> $ codesign -dvv ~/Library/Caches/Xamarin/mtbs/builds/SingleViewClassic/4768660f460b113006192b6ee7095868/bin/iPhone/Debug/SingleViewClassic.app/libSingleViewClassic.exe.dylib
> /Users/macuser/Library/Caches/Xamarin/mtbs/builds/SingleViewClassic/4768660f460b113006192b6ee7095868/bin/iPhone/Debug/SingleViewClassic.app/libSingleViewClassic.exe.dylib: code object is not signed at all


## Results: Classic API MtouchFastDev crash on 3.9.236 (also tested on 3.9.274 and 3.8.150)

From Xcode -> Window -> Devices -> "Device Name" -> View Device Logs [button]

> Dyld Error Message:
>   Library not loaded: @executable_path/libSingleViewClassic.exe.dylib
>   Referenced from: /private/var/mobile/Containers/Bundle/Application/82878BAD-77F6-4B7E-8A82-50B5772E2B1F/SingleViewClassic.app/SingleViewClassic
>   Reason: no suitable image found.  Did find:
> 	/private/var/mobile/Containers/Bundle/Application/82878BAD-77F6-4B7E-8A82-50B5772E2B1F/SingleViewClassic.app/libSingleViewClassic.exe.dylib: mmap() error 1 at address=0x00164000, size=0x00002000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/82878BAD-77F6-4B7E-8A82-50B5772E2B1F/SingleViewClassic.app/libSingleViewClassic.exe.dylib
> 	/private/var/mobile/Containers/Bundle/Application/82878BAD-77F6-4B7E-8A82-50B5772E2B1F/SingleViewClassic.app/libSingleViewClassic.exe.dylib: mmap() error 1 at address=0x00169000, size=0x00002000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/82878BAD-77F6-4B7E-8A82-50B5772E2B1F/SingleViewClassic.app/libSingleViewClassic.exe.dylib
>   Dyld Version: 353.5


## Results: Unified API MtouchFastDev crash on 3.9.236 (also tested on 3.9.274)

> Dyld Error Message:
>   Library not loaded: @executable_path/libSingleViewUnified1.exe.dylib
>   Referenced from: /private/var/mobile/Containers/Bundle/Application/2D3A5F47-DE29-4A0D-A249-958D13C2126B/SingleViewUnified1.app/SingleViewUnified1
>   Reason: no suitable image found.  Did find:
> 	/private/var/mobile/Containers/Bundle/Application/2D3A5F47-DE29-4A0D-A249-958D13C2126B/SingleViewUnified1.app/libSingleViewUnified1.exe.dylib: no matching architecture in universal wrapper
> 	/private/var/mobile/Containers/Bundle/Application/2D3A5F47-DE29-4A0D-A249-958D13C2126B/SingleViewUnified1.app/libSingleViewUnified1.exe.dylib: no matching architecture in universal wrapper
>   Dyld Version: 353.5


## Expected results

On Xamarin Studio 5.7, the app builds, deploy, and runs successfully (tested using the MSBuild build engine, diagnostic build logs attached).

(See also the `codesign` commands in the verbose build logs.)


## Version information

### Windows 8.1, 64-bit

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

Xamarin   3.8.150.0 (10cfd178d55287f09c85f5a1e604dfe20889a40f)
Xamarin.Android   4.20.0.28 (ba9bbbdd44cfdc4bf485e8885bd2ad24fba525f7)
Xamarin.iOS   8.4.0.0 (840a925103a0bf4a856507f13d5eaee3c1579c2f)


### Mac OS X 10.9.5

=== Xamarin Studio ===

Version 5.7 (build 661)
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.4.0.43 (Business Edition)
Hash: 840a925
Build date: 2014-11-16 21:03:22-0500

=== Build Information ===

Release ID: 507000661
Git revision: b70bab61da996da29045ea8ee8aed1a6faedbe78
Build date: 2015-01-05 16:31:31-05
Xamarin addins: 82f6c71490562d6cd125a09287f441902fdac3d7
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2015-01-22 23:01:39 UTC
Created attachment 9460 [details]
Diagnostic build logs
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2015-01-26 00:09:26 UTC
Additional related (but probably separate) bugs in iOS:

- Bug 26404
- Bug 26405
Comment 3 rtgasi 2015-03-18 20:04:57 UTC
+1 Same issue here. Works perfectly on Xamarin Studio in a mac
Comment 7 Brendan Zagaeski (Xamarin Team, assistant) 2016-02-17 19:33:00 UTC
## Verification status: verified fixed on master

### GOOD: latest master

XamarinVS   master/a9f2066ad9c6af2218cc641b8185bb946d6fab57
Xamarin.iOS master/112204f

### BAD: Cycle 6 – Service Release 1

XamarinVS   4.0.1.96 (dcea9c1)
Xamarin.iOS 9.4.1.25 (962a050)




## Steps to verify on Classic API

1. Under "Project properties -> iOS Build -> Advanced [tab]" enable "Use SGen generational garbage collector." (Without this you will now get a build warning: "Incremental builds (--fastdev) is not supported with the Boehm GC. Incremental builds will be disabled.")

2. Run the app on an iOS 8 (or higher device).




## Results on Classic API (using the original test case)

The `.dylib` files are now signed correctly:

> codesign --verify -vvv /Users/macuser/Library/Caches/Xamarin/mtbs/builds/SingleViewClassic/28fe30e9acb6ca6c82b8ad0f3229e106/bin/iPhone/Debug/SingleViewClassic.app/libSingleViewClassic.exe.dylib 
> /Users/macuser/Library/Caches/Xamarin/mtbs/builds/SingleViewClassic/28fe30e9acb6ca6c82b8ad0f3229e106/bin/iPhone/Debug/SingleViewClassic.app/libSingleViewClassic.exe.dylib: valid on disk
> /Users/macuser/Library/Caches/Xamarin/mtbs/builds/SingleViewClassic/28fe30e9acb6ca6c82b8ad0f3229e106/bin/iPhone/Debug/SingleViewClassic.app/libSingleViewClassic.exe.dylib: satisfies its Designated Requirement

And the app runs without error on an iOS 8 device.




## Results on Unified API (using the "steps to reproduce" from Comment 0)

The `.dylib` files are now signed correctly:

> codesign --verify -vvv /Users/macuser/Library/Caches/Xamarin/mtbs/builds/UnifiedSingleViewIphone1/9c59b12813521598f8c3d0554dc0f47d/bin/iPhone/Debug/UnifiedSingleViewIphone1.app/libUnifiedSingleViewIphone1.exe.dylib
> /Users/macuser/Library/Caches/Xamarin/mtbs/builds/UnifiedSingleViewIphone1/9c59b12813521598f8c3d0554dc0f47d/bin/iPhone/Debug/UnifiedSingleViewIphone1.app/libUnifiedSingleViewIphone1.exe.dylib: valid on disk
> /Users/macuser/Library/Caches/Xamarin/mtbs/builds/UnifiedSingleViewIphone1/9c59b12813521598f8c3d0554dc0f47d/bin/iPhone/Debug/UnifiedSingleViewIphone1.app/libUnifiedSingleViewIphone1.exe.dylib: satisfies its Designated Requirement

And the app runs without error on an iOS 8 device.
Comment 8 Brendan Zagaeski (Xamarin Team, assistant) 2016-02-17 19:39:15 UTC
## Status update for any users CC'd on the bug report

As now recorded in Comment 7, this issue has been fixed in the latest internal development builds. As long as no additional problems are identified with that candidate fix, it will be included in the next release that is "branched from master." At the moment that will tentatively place the fix in "Cycle 7," and the hope is to have the first preview versions of "Cycle 7" available during the month of February.
Comment 9 Rajneesh Kumar 2016-05-18 19:20:48 UTC
I have checked this issue with the following XVS from cycle7:
Xamarin.VisualStudio_4.1.0.503_d6e750ab4dc11c09c582fe53ca94618f97e88594

Now I am successfully able to build and deploy the attached test sample on device (iOS 9.3.1) successfully.

Thanks..!