Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS binding returns NULL on .NET8 #19856

Closed
Kebechet opened this issue Jan 18, 2024 · 6 comments
Closed

iOS binding returns NULL on .NET8 #19856

Kebechet opened this issue Jan 18, 2024 · 6 comments
Labels
need-attention An issue requires our attention/response
Milestone

Comments

@Kebechet
Copy link

Steps to Reproduce

  1. I have created simple example with the bug in this repo
  2. Download it and try to run main branch. It contains .NET7 version of the binding Kebechet.Maui.RevenueCat.iOS. In App.xaml.cs L17 put breakpoint and run it on your iPhone. When it reach the breakpoint result should be filled with some value.
  3. Now change branch to _net8. This branch has changed versions of the framework to .NET8+ binding with version 4.31.9-preview1 what is the same binding but with changed version of .NET. Ofc before running this remove bin & obj, restore packages and run. In this case when breakpoint is triggered the result contains NULL.

Expected Behavior

.NET8 version should return object as .NET7 one

Actual Behavior

Null is returned from the method Purchases.ConfigureWithAPIKey

Environment

Version information
Microsoft Visual Studio Enterprise 2022
Version 17.8.4
VisualStudio.17.Release/17.8.4+34408.163
Microsoft .NET Framework
Version 4.8.09032

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools   00482-20500-62150-AA814
Microsoft Architecture Diagrams and Analysis Tools

Visual C++ 2022   00482-20500-62150-AA814
Microsoft Visual C++ 2022

ADL Tools Service Provider   1.0
This package contains services used by Data Lake tools

ASA Service Provider   1.0

ASP.NET and Web Tools   17.8.358.6298
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.8.358.6298
Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio   2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools   17.8.358.6298
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio   2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools   4.8.0-7.23572.1+7b75981cf3bd520b86ec4ed00ec156c8bc48e4eb
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Entity Framework Core Power Tools   2.5
Adds useful design-time EF Core DbContext features to the Visual Studio Solution Explorer context menu.

Extensibility Message Bus   1.4.39 (main@e8108eb)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Fine Code Coverage   FineCodeCoverage2022.ad53fb28-7a11-4465-a27a-3550499ea4a1
Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)

GitHub Copilot   1.147.0.0 (v1.147.0.0@218a5ecac)
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.

GitHub Copilot Agent   1.147.0

IndentRainbowPackage Extension   1.0
IndentRainbowPackage Visual Studio Extension Detailed Info

Microsoft Azure Hive Query Language Service   2.6.5000.0
Language service for Hive query

Microsoft Azure Stream Analytics Language Service   2.6.5000.0
Language service for Azure Stream Analytics

Microsoft Azure Tools for Visual Studio   2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio   17.8.17 (957fbed)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.8.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Project System Tools   1.0
Tools for working with C#, VisualBasic, and F# projects.

Razor (ASP.NET Core)   17.8.3.2358002+8c7fb27bf8e8d4f9ff8080b624b35bca5e812e97
Provides languages services for ASP.NET Core Razor.

ResX Resource Manager   ResXManager
Manage localization of all ResX-based resources in one place. Shows all resources of a solution and lets you edit the strings and their localizations in a well-arranged data grid.

SQL Server Data Tools   17.8.120.1
Microsoft SQL Server Data Tools

Switch Startup Project   4.2.76
Provides a toolbar dropdown box  to switch between startup projects.

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript Tools   17.0.20920.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   4.8.0-7.23572.1+7b75981cf3bd520b86ec4ed00ec156c8bc48e4eb
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools   17.8.0-beta.23475.2+10f956e631a1efc0f7f5e49c626c494cd32b1f50
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

Xamarin   17.8.0.157 (d17-8@8e82278)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.8.3.6 (remotes/origin/d17-8@eccf46a291)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   17.8.16 (830b56a)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   13.2.2.0 (d17-5/45b0e14)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: d9a6e87
    Java.Interop: xamarin/java.interop/d17-5@149d70fe
    SQLite: xamarin/sqlite/3.40.1@68c69d8
    Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d


Xamarin.iOS and Xamarin.Mac SDK   16.4.0.23 (9defd91b3)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Build Logs

msbuild.zip

Example Project (If Possible)

Testing project: https://github.com/Kebechet/BugBinding

  • testing project contains 2 branches:
    • main - containing working .NET7 test project where in App.xaml.cs call Purchases.ConfigureWithAPIKey returns some value
    • _net8 - .NET8 proejct where the call returns NULL

Binding project: https://github.com/Kebechet/Maui.RevenueCat.iOS

  • binding project contains
    • main branch containing working .NET7 binding and
    • NET8 branch which is released in nuget as 4.31.9.1-preview1 and has only changed framework version from NET7 to NET8
@Kebechet
Copy link
Author

After some trial and error I was able to make the library work but only with remote device (iPhone connected with cable to MAC into which I am connected remotely from Windows - my main machine).
With Local device (iphone connected to Windows) it keeps giving me NULL.

@rolfbjarne
Copy link
Member

The main branch of the test project doesn't compile for me:

error : ld: Undefined symbols: [/Users/rolf/test/bugs/BugBinding/BugBinding/BugBinding.csproj::TargetFramework=net7.0-ios]
error :   _OBJC_CLASS_$_FakeASIdManager, referenced from: [/Users/rolf/test/bugs/BugBinding/BugBinding/BugBinding.csproj::TargetFramework=net7.0-ios]
error :        in registrar.o [/Users/rolf/test/bugs/BugBinding/BugBinding/BugBinding.csproj::TargetFramework=net7.0-ios]
[...]]

which is because it seems the symbol is a mangled symbol:

$ nm /Users/rolf/test/bugs/BugBinding/BugBinding/obj/Debug/net7.0-ios/ios-arm64/linker-cache/RevenueCat.framework/RevenueCat|g _OBJC_CLASS_.*FakeASIdManager
000000000025b0c8 s _OBJC_CLASS_$__TtC10RevenueCat15FakeASIdManager

(this means the native class name is actually _TtC10RevenueCat15FakeASIdManager, not FakeASIdManager).

Also I recommend using the .xcframework shipped by RevenueCat instead of the .framework (this is required to support the simulator on ARM64 macOS machines). There's bit more info here: https://github.com/xamarin/xamarin-macios/wiki/.NET-8-release-notes#default-runtimeidentifiers

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label Jan 23, 2024
@rolfbjarne rolfbjarne added this to the Future milestone Jan 23, 2024
@Kebechet
Copy link
Author

Thank you for the tip on .xcframework. For now you can probably close this. When I have time I will try to change the binding and if I have still some problems we can reopen this.

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Jan 23, 2024
@akravch
Copy link

akravch commented Feb 7, 2024

Hello @rolfbjarne ,

I am experiencing a similar issue when consuming a binding library from a .NET 8 application. In my case I noticed that NSString constants that used to return something meaningful on .NET 7 now return null.

I too have a repro project here: https://github.com/akravch/IosNet8Binding

In this sample I bind to a PLCrashReporter static library (https://github.com/microsoft/plcrashreporter/releases/tag/1.11.1), but the behaviour seems to be the same regardless of the library.

This sample is supposed to render "PLCrashReporterException" from here, but on .NET 8 it always returns null. Switching the target framework of the consumer project fixes the issue and "PLCrashReporterException" is rendered as expected.

Switching to .xcframework is not always convenient/possible, so could you please revisit and probably reopen this issue?

@rolfbjarne
Copy link
Member

@akravch please create a new issue so that we don't end up confusing potentially two different problems

@akravch
Copy link

akravch commented Feb 8, 2024

@akravch please create a new issue so that we don't end up confusing potentially two different problems

Leaving the link for the history: #20061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-attention An issue requires our attention/response
Projects
None yet
Development

No branches or pull requests

3 participants