marcojak / MauiMTAdmob

MIT License
110 stars 18 forks source link

Running .NET MAUI 8 app on real iOS device getting error - Undefined symbols for architecture arm64 #60

Closed khambley closed 1 month ago

khambley commented 8 months ago

/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/17.0.8478/targets/Xamarin.Shared.Sdk.targets(3,3): Error: clang++ exited with code 1: Undefined symbols for architecture arm64: "_OBJCCLASS$_UMPConsentForm", referenced from: objc-class-ref in registrar.o "_OBJCCLASS$_UMPConsentInformation", referenced from: objc-class-ref in registrar.o "_OBJCCLASS$_UMPDebugSettings", referenced from: objc-class-ref in registrar.o "_OBJCCLASS$_UMPRequestParameters", referenced from: objc-class-ref in registrar.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

This build error only occurs when I try to test on my physical iOS devices running iOS 17.2. The plugin works fine on the iOS simulators. I'm building and running it on a Mac in VS for Mac, 17.6.8. Android works fine on simulators and physical devices. I'm running Xcode 15.0.1. I see there is an update for Xcode to 15.2. I'll try updating it and see if that solves it.

erossini commented 8 months ago

The cards are not your fault, I agree 😁 but if you want to fix them...

erossini commented 8 months ago

I happily fixed my cards problem. Still the issue with Xamarin.Google.iOS.UserMessagingPlatform

image

marcojak commented 8 months ago

for now, you can just include Xamarin.Google.iOS.UserMessagingPlatform 1.1.0.1 and that should fix it but I'm trying to understand how to fix it without adding it to the iOS project.

khambley commented 8 months ago

I haven't tried your sample. I started with a new clean MAUI .net 8 project on my PC connected to my Mac. I did create a new MAUI project on my Mac as well and it wouldn't let me load your nuget package. It said it was incompatible with maccatalyst. It seems to install okay but it won't recognize the Plugin.MauiMTAdmob namespace so I can't call it in the project. It won't build. All of my software is up to date with the latest stable versions, Xcode 15.2, macOs Sonoma 14.3, Visual Studio for Mac 17.6.8

marcojak commented 8 months ago

I found the null object but I'm identifying why on the simulator doesn't work..

marcojak commented 8 months ago

I've released version 1.1.3 of the plugin to avoid the crash on the simulator. I'm not sure why the consent sharedinstance is null on a simulator and works fine on the real device but most important I'm not sure why it used to work fine (on the simulator) and now it doesn't. I've tried to compile a previous commit but nothing. And given that the code used to work and now the same code doesn't work, I'm inclined to think that this happened after I've updated something (I've updated VS on Windows, VS for MAC and XCode). I'll continue to investigate and see what I can do to make it work on the simulator

erossini commented 8 months ago

Thank you so much!

marcojak commented 8 months ago

I've just released version 1.2.0 The news is that it supports App Open Ads for Android and iOS.

Let me know if this version works well and you can normally compile your code...

khambley commented 7 months ago

So I cannot install the update for the plugin 1.2.0 on VS for Mac. 17.6.8 (build 400). Error Message: Package Plugin.MauiMTAdmob 1.2.0 is not compatible with net8.0-ios17.0 (.NETCoreApp,Version=v8.0). Package Plugin.MauiMTAdmob 1.2.0 supports:

marcojak commented 7 months ago

Let me check if I can change it...I'm adding back .net7 as well for some projects that might still be stuck with that so I'll see if I can also change this compatibility with ios17.0

On Wed, 7 Feb 2024, 18:38 Katherine Hambley, @.***> wrote:

So I cannot install the update for the plugin 1.2.0 on VS for Mac. 17.6.8 (build 400). Error Message: Package Plugin.MauiMTAdmob 1.2.0 is not compatible with net8.0-ios17.0 (.NETCoreApp,Version=v8.0). Package Plugin.MauiMTAdmob 1.2.0 supports:

  • net8.0-android34.0 (.NETCoreApp,Version=v8.0)
  • net8.0-ios17.2 (.NETCoreApp,Version=v8.0)
  • net8.0-maccatalyst17.2 (.NETCoreApp,Version=v8.0)
  • net8.0-windows10.0.19041 (.NETCoreApp,Version=v8.0) I have the latest stable XCode version 15.2. My iOS Simulators are iOS 17.2 and my physical devices are 17.2. My dotnet version is 8.0.100 which from what I can tell is the latest stable version. I've tried everything I can think of to upgrade the net8.0-ios17.0 to 17.2, am at a loss. Does anyone know how to update that framework to 17.2?

— Reply to this email directly, view it on GitHub https://github.com/marcojak/MauiMTAdmob/issues/60#issuecomment-1932555116, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAUIPITMRD2W72NKRVZXBF3YSO32VAVCNFSM6AAAAABCRR7RJWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZSGU2TKMJRGY . You are receiving this because you were mentioned.Message ID: @.***>

marcojak commented 7 months ago

Do you have an empty sample project that gives you the error and that I can try? If so, send it and I'll see what I can do.

The plugin just targets net8.0-ios

with 15.4

So I'm not sure yet why you are seeing the error but I'm investigating it.

marcojak commented 7 months ago

Can you check that in your targetFrameworks you have

net8.0-android;net8.0-ios;net8.0-maccatalyst

and not this:

net8.0-android;net8.0-ios17.0;net8.0-maccatalyst

?

khambley commented 7 months ago

So I updated my .NET 8 SDK, created a new blank .NET MAUI project on VS for Mac. I installed the latest version of plugin and I get that "Error: clang++ exited with code 1: Undefined symbols for architecture arm64: "OBJC_CLASS$_UMPConsentForm", referenced from: objc-class-ref in registrar.o"... error. I tried to install the Xamarin.Google.iOS.UserMessagingPlatform version 1.1.0.1. I'm not sure how to target just the iOS project in MAUI so it tried to install in all of them presumably. I get a weird the Name of the assembly does not match the target name in Android. The app installs on iOS device but crashes right after the launch screen. I installed the Xamarin.Google.iOS.UserMessagingPlatform version 1.2.0.5 and same thing, iOS app installs but crashes. When I try it on Android, it says "failed processing manifest" and fails.

marcojak commented 7 months ago

Don't install Xamarin.Google.iOS.UserMessagingPlatform version 1.2.0.5 , it's totally another package (not from xamarin)

Have a look at my previous comment, maybe it helps.

I've just tested an empty project on VS for Mac, same version as you have, with same xcode and simulator version and it works...make sure your targetframework is correct, once I got the same issue and it was just that...

khambley commented 7 months ago

..make sure your target framework is correct... What framework should I target? This is what is in my proj file: <TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks> And here is my

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
        <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>

I just pushed up the repo I'm working with, the blank project I just created. https://github.com/khambley/RockBandNameGenerator2

khambley commented 7 months ago

This is the error I get when trying to install the Xamarin.Google.ios.UserMessagingPlatform 1.1.0.1 <PackageReference Include="Xamarin.Google.iOS.UserMessagingPlatform" Version="1.1.0.1" Condition="'$(TargetFramework)' == 'net8.0-ios'"/> Error while trying to load the project '/Users/katherinehambley/Projects/RockBandNameGenerator2/RockBandNameGenerator2.csproj': The '_GoogleUserMessagingPlatformAssemblyName' start tag on line 3 position 6 does not match the end tag of '_GoogleMobileAdsAssemblyName'. Line 3, position 132. /Users/katherinehambley/.nuget/packages/xamarin.google.ios.usermessagingplatform/1.1.0.1/buildTransitive/Xamarin.Google.iOS.UserMessagingPlatform.targets and I can't load the project at all in VS

marcojak commented 7 months ago

It's a known issue with the xamarin plugin...I'm trying to solve this as annoying but meanwhile you can solve following this:

Open the file "xamarin.google.ios.usermessagingplatform\1.1.0.1\buildTransitive\Xamarin.Google.iOS.UserMessagingPlatform.targets"

Replace the line

<_GoogleUserMessagingPlatformAssemblyName>Google.UserMessagingPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null with <_GoogleUserMessagingPlatformAssemblyName>Google.UserMessagingPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null That will fix the issue!
khambley commented 7 months ago

Yep, I got it to build successfully! Thank you. Now I'm going to implement the plugin and see if I can get a banner ad to show up. Thanks again! :)

khambley commented 7 months ago

So, I got it to run and ads show up on the iOS Simulator, however, it launches on my iPhone but crashes. Here is what is in the logs: The entry point method could not be loaded due to Could not resolve type with token 01000028 from typeref (expected class 'System.Object' in assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a') assembly:System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a type:System.Object member:(null) I've restored all the .NET workloads using dotnet package restore on the CL. Any ideas?

khambley commented 7 months ago

OMG, I got it to run on my iPhone, yess!! So, I created a new .NET MAUI project in VS for Mac, installed the plugin, wired it up with a test ad unit id and viola! it works! It's a pretty simple app so I can just migrate my code to this new project. It's was just an app I created for learning .NET MAUI and Admob. Not sure if it's ready for a business app, though. Gonna do some more testing. Thank you for sticking with me!

erossini commented 7 months ago

I'm going to update my app today. Let you know 😉

marcojak commented 7 months ago

OMG, I got it to run on my iPhone, yess!! So, I created a new .NET MAUI project in VS for Mac, installed the plugin, wired it up with a test ad unit id and viola! it works! It's a pretty simple app so I can just migrate my code to this new project. It's was just an app I created for learning .NET MAUI and Admob. Not sure if it's ready for a business app, though. Gonna do some more testing. Thank you for sticking with me!

I'm glad everything works. Always happy to help!

erossini commented 7 months ago

Sorry, I'm late to the party. I have just installed version 1.2.1 and when I deploy it on a real device, I get this error

error MT1045: Failed to execute 'devicectl': 'devicectl -j /var/folders/dm/bwmxpbzn6bvdsyy73c_b453w0000gn/T/tmpZlCLVY.tmp device install app --device "Enrico???s iPhone" /Users/enrico/Library/Caches/Xamarin/mtbs/builds/LanguageInUse/1fa03704bb15e35c6f47a701d9d92131e3e0740198296a93338bb3c829bc9cf7/bin/Debug/net8.0-ios/ios-arm64/device-builds/iphone15.2-17.3.1/LanguageInUse.app' returned the exit

clang++ exited with code 1: Undefined symbols for architecture arm64: "_OBJCCLASS$_UMPConsentForm", referenced from: objc-class-ref in registrar.o "_OBJCCLASS$_UMPConsentInformation", referenced from: objc-class-ref in registrar.o "_OBJCCLASS$_UMPDebugSettings", referenced from: objc-class-ref in registrar.o "_OBJCCLASS$_UMPRequestParameters", referenced from: objc-class-ref in registrar.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) LanguageInUse C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\17.2.8004\targets\Xamarin.Shared.Sdk.targets 1559

Before that, I removed the reference to the Xamarin.Google.iOS.UserMessagingPlatform.

marcojak commented 7 months ago

For this issue for now you need to reference that package in your iOS project. I'm still investigating it and see how to solve this.

erossini commented 7 months ago

So, I added the package back, but I still have this error.

error MT1045: Failed to execute 'devicectl': 'devicectl -j /var/folders/dm/bwmxpbzn6bvdsyy73c_b453w0000gn/T/tmp7IdFVh.tmp device install app --device "Enrico???s iPhone" /Users/enrico/Library/Caches/Xamarin/mtbs/builds/LanguageInUse/1fa03704bb15e35c6f47a701d9d92131e3e0740198296a93338bb3c829bc9cf7/bin/Debug/net8.0-ios/ios-arm64/device-builds/iphone15.2-17.3.1/LanguageInUse.app' returned the exit code 1.

It works in the Simulator. So, I tried to downgrade to version 1.2.0 with the same error. Maybe it is not related to your component...

marcojak commented 7 months ago

Mhh...i don't recognise this error. Currently I don't think it's related to this plugin. Anyway I would try to clean the project and remove bin and obj folders for a clean test.

marcojak commented 1 month ago

This should be fixed now. Closing it