question

OBE-0036 avatar image
0 Votes"
OBE-0036 asked slongietti edited

Xamarin iOS App: HealthKit reject and CustomMarshalers Bug

Hello,

our app was rejected by the Apple App Store with the notice:

“We noticed that your app uses HealthKit, but your app does not appear to include any primary features that require health or fitness data.

The intended use of HealthKit is generally to share health or fitness data with other apps or devices as a part of the app's core functionality.

To resolve this issue, please remove any HealthKit functionality from your app, as well as any references to this app’s interactivity with HealthKit from the app or its metadata. This includes removing any HealthKit-related keys in your app's Info.plist as well as removing any calls to HealthKit APIs, including those from 3rd party platforms, from your app.”



However, our app has no HealthKit functionality.

Some research has shown that the problem lies in Xamarin.Forms, and the solution can be built with "Link Framework SDKs Only".

I use Microsoft Visual Studio Professional 2019 version 16.9.4 (VisualStudio.16.Release/16.9.4+31205.134)
with Xamarin.Forms 5.0.0.2012 and MvvmCross 7.1.2.
Microsoft .NET Framework Version 4.8.04084
Xamarin 16.9.000.273
Xamarin Templates 16.9.72
Xamarin.iOS and Xamarin.Mac SDK 14.14.2.5

With "Link Framework SDKs Only" the following error occurs in the Xamarin.iOS project:

“Can't resolve the reference 'System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler', referenced from the method 'System.Collections.IEnumerator Dia2Lib.IDiaEnumTables::GetEnumerator()' in 'CustomMarshalers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxx'.”

Is a Windows update necessary here because of the system libraries and CustomMarshalers?

Greetings,
OBE


dotnet-xamarin
· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can't resolve the reference 'System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler', referenced from the method ...

Hi, OBE-0036. Did you face the error in debug mode or release mode? If it's in the debug mode, please update all the nuget packages to the lastest version and test again. The Link Framework SDKs Only option will remove some assemblies that the application doesn't use, the assembiles may be removed. Try to test the Don't Link option to vertify that. If it works with Don't Link option, you could skip the related assemblies to avoid the problem.

Check the doc: https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=macos#skipping-assemblies


0 Votes 0 ·

Many Thanks! This is in release mode. All NuGet packages have the latest version. I will try to remove the corresponding assemblies as suggested.

0 Votes 0 ·

Waiting for your update.

0 Votes 0 ·
Show more comments

Even with removing unused references via R#, this is still an issue if the MTouchLink is set to SdkOnly for our team. The real issue I see here is that Xamarin.iOS does not have a way to exclude libraries from the build such as AppleHealth. I understand that setting the Linker setting to SdkOnly will excluding unused libraries, but by doing so, you also cannot test using Hot Reload which was probably the most advertised feature of Visual Studio 2022.

Respectfully...

This may not be the forum to request for a change, but I think asking for Xamarin.iOS to have the ability to exclude libraries from the build seems fair. Especially given that the App Store Connect Review will deny apps that include libraries that are unused.



0 Votes 0 ·
JamesMontemagno-7652 avatar image
0 Votes"
JamesMontemagno-7652 answered OBE-0036 commented

You should turn on Link Framework SDKs Only when in release mode

You may need to link skip this specific interopt library:

--linkskip=System.Runtime.InteropServices


see in https://docs.microsoft.com/en-us/xamarin/ios/deploy-test/linker?tabs=macos#skipping-assemblies

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Many Thanks! I did this as you suggested. Unfortunately, the error still comes with it:

Can't resolve the reference 'System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler', referenced from the method 'System.Collections.IEnumerator Dia2Lib.IDiaEnumTables::GetEnumerator()' in 'CustomMarshalers, Version=4.0.0.0, Culture=neutral, PublicKeyToken= ...

0 Votes 0 ·

We have solved the problem. It was due to two old unused packages which we removed. Now the app can also be generated with Link Framework SDKs Only". Many thanks for the help.

0 Votes 0 ·
slongietti avatar image
0 Votes"
slongietti answered slongietti edited

You should turn on Link Framework SDKs Only for the Release configuration as @JamesMontemagno-7652 stated.

However, using that mode will ignore linkskip arguments.

What you can do is create a Custom linker xml file in root your iOS's project folder. For this example I named the file "linker.xml". Be sure to set the file to "Always copy"

<linker>
<assembly fullname="CustomMarshalers">
<type fullname="System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler"/>
</linker>

Then in your iOS's project build configuration add an additional mtouch argument

--xml=${ProjectDir}/linker.xml

Then build using the Release configuration.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.