Xamarin.Mac linker behavior, Appstore rejection

SanyaAndreichukSanyaAndreichuk Sanya AndreichukUSMember ✭✭

After updating mono mdk, xamarin.mac, xamarin studio and xcode to the latest version, Apple has rejected my app with issues

Performance - 2.1

Your app links against the GameKit framework but does not appear to include Game Center functionality.

Performance - 2.1

Your app links against the MapKit framework but does not appear to include Maps functionality.

Performance - 2.3

Your app does not achieve the core functionality described in your marketing materials or release notes.

Specifically, App is Linking against GameController framework without its functionality.

But I never use GameKit, MapKit in my code. As I understand it is related to the linker behavior, so I decided to check it in the project options, and I discovered that 'linker behavior' option is disabled with 'Don't link' value. How can I change it to 'Sdk only' value? Or how can I fix this issue ? Thanks.

Posts

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    tl;dr; - Try adding --registrar=dynamic to your mmp arguments. That should work around the issue.

    Long Version - https://medium.com/@donblas/how-a-default-behavior-change-broke-mac-app-store-submissions-bb92314065a0

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭

    @ChrisHamons I've just had the same rejection from the Mac AppStore for linking to GameKit even though I'm not using it.

    However, I'm already not linking and using --registrar:dynamic as per your suggestion earlier this year regarding another issue.
    https://forums.xamarin.com/discussion/97003/native-linking-failed-with-error-code-1-unknown-type-name-qtmovieview#latest

    Anything I'm missing?

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    So a few things:

    • All of the existing tests case (that I know of) covered 64-bit. Once 10.13 drops, you will need to move to 64-bit at some point if you want to stay in the store. (https://developer.apple.com/news/?id=06282017a)
    • --registrar:dynamic "works" as a work around, but "--linkplatform" is the preferred answer if you are using a modern Xamarin.Mac. That links Xamarin.Mac.dll and removes the API invocations completely.
    • If that doesn't work, posting a full build log (or DM me it) would be the next step, preferably with "-v -v -v -v -v" added to your mmp arguments.
  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭

    Thanks Chris!

    I think I can probably switch to 64-bit actually, good spot there, the only reason I'm targeting 32bit was because Xamarin Insights on Xam.Mac didn't support 64-bit. I've had to disable Insights completely because it appears Insights no longer supports Xamarin.Mac at all (in the Modern incarnation it seems anyway). I have another thread open about that but it isn't getting any attention from Xamarin. But that's a whole other discussion :)

    Thank you very much for your suggestions Chris, I'm going to try building targeted at 64-bit and with the --linkplatform mmp argument....

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    I've had to disable Insights completely because it appears Insights no longer supports Xamarin.Mac at all (in the Modern incarnation it seems anyway). I have another thread open about that but it isn't getting any attention from Xamarin.

    I'm sorry you aren't hearing a solid answer from that side of Xamarin/Microsoft. Insights is merging with HockeyApp (https://www.xamarin.com/insights), which as of last time I checked did not support Xamarin.Mac Modern.

    I would consider posting a feature request with that team, noting your previous use of insights.

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭
    edited September 15

    Not as successful as I would have hoped....

    First I switched to _x86_64 and tried building again. All good.

    Second, I switched the mmp arguments to --linkplatform -v -v -v -v -v --xml=Properties/System.Web.xml and tried building again.

    This time I get MMP : error MM2001: Could not link assemblies. Reason: Error processing method: 'System.String HtmlAgilityPack.HtmlWeb::GetContentTypeForExtension(System.String,System.String)' in assembly: 'HtmlAgilityPack.dll'

    I've attached the full build log that hopefully will be helpful..

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    Ok, something HtmlAgilityPack:

    Mono.Linker.MarkException: Error processing method: 'System.String HtmlAgilityPack.HtmlWeb::GetContentTypeForExtension(System.String,System.String)' in assembly: 'HtmlAgilityPack.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Net.DnsPermission::.ctor(System.Security.Permissions.PermissionState)
    
    Mono.Cecil.ResolutionException: Failed to resolve System.Void System.Net.DnsPermission::.ctor(System.Security.Permissions.PermissionState)
      at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod (Mono.Cecil.MethodReference reference) [0x00001] in /Users/builder/data/lanes/4991/8a391069/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:1448 
    

    Let's do some research:

    find /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5 -name "*.dll" -print -exec monop -r:{} \; | mvim -
    

    shows System.dll, which I can confirm with another monop. Let's check Xamarin.Mac.

    $ monop -r:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.dll | grep DnsPermission
    $ monop -r:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/System.dll | grep DnsPermission
    System.Net.DnsPermission
    

    So it's there in 4.5 but not Modern. What target framework are you using?

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭

    Yep, am using Modern not the desktop framework!

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    Then you are "getting away" with using a non-compatible due to the way that .NET loading works.

    Part of HtmlAgilityPack has a hard reference to a thing that does not exist in the System.dll you are using. However, since we JIT things, as long as you don't call that code path, you are "fine".

    This would also likely break horribly if you tried to AOT your project.

    Suggestions:

    1) Recompile HtmlAgilityPack to actually target Modern (and removing the offending code)
    2) Accept forever that you won't be able to AOT or link, since both requiring creating a call graph of all of the code, and your call graph is busted. Try to find another work around.

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭

    Yep, thanks Chris, really helpful as always!

    I'm researching suggestion 1. I'll update this thread with my progress..

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭
    edited September 16

    So I've successfully built HtmlAgilityPack for Xamarin.Mac Modern which is great and resolves this part of the problem.

    I grabbed the source from https://github.com/Clancey/HtmlAgilityPack and built it quite easily. All good there and thank you again to @DennisWelu for his thoroughness :)

    However switching from registrar:dynamic to --linkplatform seems to have brought some of the original issues back...

    error GC871EEFB: unknown type name 'QTMovieView' error G5EC502AB: expected a type error G5EC502AB: expected a type error GDA57B164: type of property 'QTMediaPlayer' ('int *') does not match type of accessor 'QTMediaPlayer' ('id') warning GDA57B164: type of property 'QTMediaPlayer' does not match type of accessor 'setQTMediaPlayer:' error GC871EEFB: unknown type name 'QTMovieView' error GC871EEFB: unknown type name 'QTMovieView' error GC871EEFB: unknown type name 'QTMovieView' error G5EC502AB: expected a type error G5EC502AB: expected a type error GD35A792B: cannot initialize return object of type 'id' with an rvalue of type 'int *' error GAF447572: no matching function for call to 'native_to_managed_trampoline_163' note: candidate function not viable: no known conversion from 'id' to 'int *' for 4th argument

    I've attached the build log and I'm wondering if it's the static registrar problem with the missing headers again.

    Some research uncovered a workaround I think you guys added to try and work round this....?

    https://github.com/xamarin/xamarin-macios/blob/master/tools/common/StaticRegistrar.cs#L2311

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    What version of Xamarin.Mac are you using / What version of xcode do you have installed/selected?

    We have work arounds for QTKit's removal (https://github.com/xamarin/xamarin-macios/blob/master/tools/common/StaticRegistrar.cs#L1836) in modern Xamarin.Mac's...

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭

    I'm using....

    Visual Studio Community 2017 for Mac
    Version 7.1.3 (build 1)
    Runtime:
        Mono 5.2.0.224 (d15-3/14f2c81) (64-bit)
        GTK+ 2.24.23 (Raleigh theme)
        Package version: 502000224
    
    Apple Developer Tools
    Xcode 8.3.3 (12175.1)
    Build 8E3004b
    
    Xamarin.iOS
    Version: 10.12.3.3 (Visual Studio Community)
    Hash: 8a391069
    Branch: d15-3
    Build date: 2017-08-28 16:51:11-0400
    
    Xamarin.Mac
    Version: 3.6.3.3 (Visual Studio Community)
    
    Build Information
    Release ID: 701030001
    Git revision: ba94259b26824844f4d2c76c794738eb75b85726
    Build date: 2017-08-25 16:28:43-04
    Xamarin addins: ee499cfb63ae406b1e394bf6a159ad2953f7fab6
    Build lane: monodevelop-lion-d15-3
    
    Operating System
    Mac OS X 10.12.6
    Darwin 16.7.0 Darwin Kernel Version 16.7.0
        Thu Jun 15 17:36:27 PDT 2017
        root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
    
  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    XM 3.6.3.3 should have that fix for sure.

    A few things:

    • Now that you rebuilt the agility pack, you could likely just ship with, registrar:dynamic, right? There still is a possible bug, which we'll work out, but that might unblock you (I can't tell from history why you were moving away from that)
    • Wait a second, why are you doing linkplatform only, your modern:

      Selected target framework: Xamarin.Mac,Version=v2.0,Profile=Mobile; API: Unified

      Modern has full access to the linker, since it doesn't have System.Configuration. Try removing linkplatform and change the link mode to SDK in your build settings.

    • We only tested link platform on the XM Full profile, not Modern (Mobile), since Mobile has the "real" linker. It should work, which I'm looking into now.

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    I did a bit of testing by building and running this over and over:

     $ otool -L bin/Release/XMTestLink.app/Contents/MacOS/XMTestLink  | grep QTKit
        /System/Library/Frameworks/QTKit.framework/Versions/A/QTKit (compatibility version 1.0.0, current version 1.0.0)
    

    Modern, Static Registrar, No Linking: Has QT
    Modern, Static Registrar, SDK Linking: No QT
    Modern, Static Registrar, Platform Linking: No QT

    I'm having trouble reproducing your issue so far, going to take another stab tomorrow morning.

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭
    edited September 20

    Deleted this post as it was a duplicate of the one below when trying to edit it !

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭
    edited September 20

    Thanks Chris..

    Now that you rebuilt the agility pack, you could likely just ship with, registrar:dynamic, right?

    I don't think so, I was shipping with registrar:dynamic before and that's when Apple came back and said I should stop linking to the GameKit framework. The QTKit problem only appeared when I started using the static registrar.

    Hope that makes sense?

    Modern has full access to the linker, since it doesn't have System.Configuration. Try removing linkplatform and change the link mode to SDK in your build settings.

    I'll do some testing with your suggestions and otool to see if I can see anything GameKit related.

  • KeithBoyntonKeithBoynton Keith Boynton GBMember ✭✭

    Ok so the results:

    When building: Linker behaviour: Don't Link and mmp arguments: --registrar:dynamic -v -v -v -v -v --xml=Properties/System.Web.xml

    otool -L x.app/Contents/MacOS/x | grep GameKit
        /System/Library/Frameworks/GameKit.framework/Versions/A/GameKit (compatibility version 1.0.0, current version 471.7.2)
    

    When building: Linker behaviour: Link Framework SDKs Only and mmp arguments: -v -v -v -v -v --xml=Properties/System.Web.xml

    obj/x86/AppStore/mmp-cache/registrar.h(1062,46): warning GDA57B164: type of property 'QTMediaPlayer' does not match type of accessor 'setQTMediaPlayer:'
    obj/x86/AppStore/mmp-cache/registrar.h(1062,32): error GC871EEFB: unknown type name 'QTMovieView'
    obj/x86/AppStore/mmp-cache/registrar.h(1130,4): error G5EC502AB: expected a type
    obj/x86/AppStore/mmp-cache/registrar.h(1131,28): error G5EC502AB: expected a type
    obj/x86/AppStore/mmp-cache/registrar.h(1062,46): error GDA57B164: type of property 'QTMediaPlayer' ('int *') does not match type of accessor 'QTMediaPlayer' ('id')
    obj/x86/AppStore/mmp-cache/registrar.m(8442,8): error GC871EEFB: unknown type name 'QTMovieView'
    obj/x86/AppStore/mmp-cache/registrar.m(8446,2): error GC871EEFB: unknown type name 'QTMovieView'
    obj/x86/AppStore/mmp-cache/registrar.m(8488,99): error GC871EEFB: unknown type name 'QTMovieView'
    obj/x86/AppStore/mmp-cache/registrar.m(16047,4): error G5EC502AB: expected a type
    obj/x86/AppStore/mmp-cache/registrar.m(16053,28): error G5EC502AB: expected a type
    obj/x86/AppStore/mmp-cache/registrar.m(16050,10): error GD35A792B: cannot initialize return object of type 'id' with an rvalue of type 'int *'
    obj/x86/AppStore/mmp-cache/registrar.m(16056,3): error GAF447572: no matching function for call to 'native_to_managed_trampoline_163'
    

    When building: Linker behaviour: Link Framework SDKs Only and mmp arguments: --registrar:dynamic -v -v -v -v -v --xml=Properties/System.Web.xml

    otool -L Trackhunter.app/Contents/MacOS/Trackhunter | grep .framework
        /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1349.64.0)
        /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57740.51.2)
        /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 775.19.0)
        /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1070.22.0)
        /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45.0.0, current version 1504.82.104)
        /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1349.63.0)
        /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon (compatibility version 2.0.0, current version 157.0.0)
        /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 603.1.30)
        /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/JavaScriptCore (compatibility version 1.0.0, current version 603.1.30)
        /System/Library/Frameworks/QTKit.framework/Versions/A/QTKit (compatibility version 1.0.0, current version 1.0.0)
        /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore (compatibility version 1.2.0, current version 1.11.0)
        /System/Library/Frameworks/CloudKit.framework/Versions/A/CloudKit (compatibility version 1.0.0, current version 651.14.0)
    

    So the last one looks good, I've submitted to the AppStore. Thank you Chris, I'm learning and thank you for your help!

  • ChrisHamonsChrisHamons Chris Hamons USXamarin Team Xamurai

    Linking the SDK + static registrar should be working.

    Could you look at your build log, find the registrar.m file, and privately message it to me. I want to see what's going on.

    Glad you have a path forward.

Sign In or Register to comment.