Bug 42139 - "Could not AOT the assembly ... Facebook.dll" when attempting to build for device in the Debug configuration with "Enable incremental builds" switched on
Summary: "Could not AOT the assembly ... Facebook.dll" when attempting to build for de...
Status: RESOLVED FIXED
Alias: None
Product: Components
Classification: Xamarin
Component: Xamarin Components ()
Version: Production (addons.xamarin.com)
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Israel Soto [MSFT]
URL:
: 41234 41999 ()
Depends on:
Blocks:
 
Reported: 2016-06-24 00:55 UTC by Brendan Zagaeski (Xamarin Team, assistant)
Modified: 2016-11-09 21:29 UTC (History)
6 users (show)

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


Attachments
Test case (10.39 KB, application/zip)
2016-06-24 00:55 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details
Diagnostic build output, detailed version info (18.34 KB, application/zip)
2016-06-24 00:56 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 FIXED

Description Brendan Zagaeski (Xamarin Team, assistant) 2016-06-24 00:55:45 UTC
Created attachment 16469 [details]
Test case

"Could not AOT the assembly ... Facebook.dll" when attempting to build for device in the Debug configuration with "Enable incremental builds" switched on




## Temporary Workaround

Switch off "Project Options > Build > iOS Build > Enable incremental builds".




## Regression status: a bug in the Xamarin.Facebook.iOS library, exposed by the more precise AOT build process in Xamarin.iOS 9.8

BAD:  Xamarin.Facebook.iOS 4.12.0 + Xamarin.iOS 9.8.1.4   (3cf8aae)
BAD:  Xamarin.Facebook.iOS 4.12.0 + Xamarin.iOS 9.8.0.323 (39ebb77)
GOOD: Xamarin.Facebook.iOS 4.12.0 + Xamarin.iOS 9.6.2.4   (d8bedd0)


Although Xamarin.iOS 9.6 does not hit this issue, the new behavior of the Xamarin.iOS 9.8 AOT process is in fact more "correct."  The bug in this case is that none of the `.linkwith.cs` files in the Xamarin.Facebook.iOS library [1] specify a dependency on the CoreGraphics framework.  Those `.linwith.cs` files will need to be updated to address this issue.

[1] https://github.com/xamarin/FacebookComponents/tree/99dc441485910cbb0819360f4ce622f741abac60/Facebook.iOS/source/Facebook


(For example, in my quick local tests, adding `Frameworks = "CoreGraphics"` at the end of the `LinkWith` attribute in `Frameworks = "CoreGraphics"` in `FBSDKCoreKit.linkwith.cs` was sufficient to stop the problem.)




## Steps to replicate

Attempt to build the attached test case in the "Debug|iPhone" configuration.



### Steps followed to create the test case

1. Create a new Single View iPhone application.

2. Add the Xamarin.Facebook.iOS 4.12.0 NuGet package to the project.

3. Reference a type from the Facebook library in one of the C# files.  For example, add the following line somewhere:
var x = typeof (Facebook.CoreKit.AccessToken);




## BAD Results (on Xamarin.iOS 9.8)



### Error list

> Error MT3001: Could not AOT the assembly '/Users/Shared/Projects/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/iPhone/Debug/mtouch-cache/64/Build/Facebook.dll'


### Excerpt from the diagnostic build output

> Process exited with code 1, command:
> 		/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
> 		  -framework Foundation
>                 -framework UIKit
> 		  /Users/Shared/Projects/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/iPhone/Debug/mtouch-cache/Bolts.a
> 		  /Users/Shared/Projects/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/iPhone/Debug/mtouch-cache/FBSDKCoreKit.a
> 		  /Users/Shared/Projects/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/iPhone/Debug/mtouch-cache/FBSDKLoginKit.a
> 		  /Users/Shared/Projects/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/iPhone/Debug/mtouch-cache/FBSDKMessengerShareKit.a
> 		  /Users/Shared/Projects/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/iPhone/Debug/mtouch-cache/FBSDKShareKit.a
> 		  /Library/Frameworks/Xamarin.iOS.framework/Versions/9.8.0.323/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonosgen-2.0.dylib
> 		  /Library/Frameworks/Xamarin.iOS.framework/Versions/9.8.0.323/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libxamarin-debug.dylib
> 		  -lz -ObjC -isysroot
> 		  /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk
> 		  -Qunused-arguments -miphoneos-version-min=8.0 -arch arm64
> 		  -shared -read_only_relocs suppress -install_name
> 		  @executable_path/libFacebook.dll.dylib -fapplication-extension
> 		  -o
> 		  /Users/Shared/Projects/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/iPhone/Debug/mtouch-cache/Facebook.dll.arm64.dylib
> 		  -x assembler
> 		  /Users/Shared/Projects/UnifiedSingleViewIphone1/UnifiedSingleViewIphone1/obj/iPhone/Debug/mtouch-cache/Facebook.dll.arm64.s
> 		  -DDEBUG
> 		Undefined symbols for architecture arm64:
> 		  "_CGAffineTransformIdentity", referenced from:
> 		      -[FBSDKWebDialog _transformForOrientation] in FBSDKCoreKit.a(FBSDKWebDialog.o)
> 		      -[FBSDKWebDialog _updateViewsWithScale:alpha:animationDuration:completion:] in FBSDKCoreKit.a(FBSDKWebDialog.o)




## GOOD Results (on Xamarin.iOS 9.6) 

The `clang` command line includes 3 more framework options compared to Xamarin.iOS 9.8:

-framework Accounts
-framework CFNetwork
-framework CoreGraphics



The `clang` command line on Xamarin.iOS 9.6 also _omits_ a few options that are _present_ on Xamarin.iOS 9.8, but I believe those can be ignored for this particular issue:

-fapplication-extension
-lz
-/Library/Frameworks/Xamarin.iOS.framework/Versions/9.8.0.323/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libxamarin-debug.dylib
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2016-06-24 00:56:43 UTC
Created attachment 16470 [details]
Diagnostic build output, detailed version info
Comment 2 Brendan Zagaeski (Xamarin Team, assistant) 2016-06-24 01:00:59 UTC
*** Bug 41234 has been marked as a duplicate of this bug. ***
Comment 3 Brendan Zagaeski (Xamarin Team, assistant) 2016-06-24 01:04:17 UTC
*** Bug 41999 has been marked as a duplicate of this bug. ***
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2016-06-24 01:25:08 UTC
## Additional information from one of the duplicate bugs

Why does disabling incremental builds help?

> The reason this works when incremental builds is off, is that in that
> case we build everything together at once, and there are other parts
> of your app that makes us link with CoreGraphics. When incremental
> builds are on, we build each assembly separately, and that also means
> that the dependencies for each assembly must be correct.
Comment 5 jstawski 2016-06-24 01:49:39 UTC
Brendan, so this sounds like it can be fixed by the Xamarin.Facebook.iOS team. When can we expect a fix?
Comment 6 Israel Soto [MSFT] 2016-07-08 17:07:20 UTC
Added these frameworks in WeakFrameworks parameter:

- Accounts
- CoreLocation
- Social
- Security
- QuartzCore
- CoreGraphics
- UIKit
- Foundation
- AudioToolbox

As it states Facebook on its cocoapods spec:

https://github.com/CocoaPods/Specs/blob/master/Specs/FBSDKCoreKit/4.13.1/FBSDKCoreKit.podspec.json#L20-L30

Adding these missing frameworks make the app build without a problem.

This fix will be available on version 4.13.1.0 of Facebook iOS component or, for now until the component is released, you can build it by yourself in the following GitHub Xamarin repo:

https://github.com/xamarin/FacebookComponents

If you have any doubt, don't hesitate to ask.

Greetings,
Israel Soto
--
Comment 7 Paul Roy 2016-08-03 06:59:31 UTC
Hi,

Just to let you know this happens also with Google.SignIn.dll (from nuget package https://www.nuget.org/packages/Xamarin.Google.iOS.SignIn/)

Thanks for the workaround and the fix
Comment 8 Valerio Santinelli 2016-11-09 17:50:58 UTC
This is still happening with Google.MobileAds on iOS as well.
Comment 9 Israel Soto [MSFT] 2016-11-09 18:25:17 UTC
Valero, in your App project options, go to Build > iOS Build, select Debug configuration and iPhone platform and verify if you have checked "Enable incremental builds", if so, please uncheck that option and try to compile again.

Let me know your status.

Greetings,
Israel Soto.
--
Comment 10 Valerio Santinelli 2016-11-09 19:44:37 UTC
Yes, disabling incremental builds solves the problem. It would be nice to be able to keep it enabled if at all possible though
Comment 11 Israel Soto [MSFT] 2016-11-09 21:29:33 UTC
@Valero, this is a known issue, we are working to solve it. You can follow the bug here:

https://bugzilla.xamarin.com/show_bug.cgi?id=43689