Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Added one missing and fixed one existing API definition. #585

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

simspace-dr
Copy link

@simspace-dr simspace-dr commented Nov 14, 2022

ICustomNativeAdLoaderDelegate was missing, preventing the ability to receive a Custom Native Ad that was requested.

CustomClickHandler also needs a set method, so the handler can be overridden to change or prevent default click behavior when desired.

@Picao84
Copy link

Picao84 commented Nov 26, 2022

Could this be merged? Native Ads are badly broken at the moment and I didn't manage to do a local build at all as the external dependencies are not downloading (maybe because the file is empty?).

@webwarrior06
Copy link

How can I compile this one to use in my project?

@Picao84
Copy link

Picao84 commented Feb 18, 2023

You can only do it in a Mac and even then you need to install different versions of the tools that come pre-installed with MacOS. I managed to build nuggets with fixes with API Definitions for Native Ads and Rewarded Interstitials, if that's what you are looking for.

@webwarrior06
Copy link

Yeah. That is exactly what I am looking for. I am using Mac. Do you have some resources/steps to do it on the mac? I would be grateful if you have. We are falling behind. It is 10.x Admob out there. :(

@Picao84
Copy link

Picao84 commented Feb 19, 2023

I didn't update version to 10, just fixed the API Definitions. I can upload the nuget files and you can add them manually if you want. I "solved" how to build a few months ago and honestly don't remember all the steps. It took several days to crack it all.

@webwarrior06
Copy link

webwarrior06 commented Feb 19, 2023

Okay, you can just upload it. :) Thanks! It will solve my current problem after all.

@Picao84
Copy link

Picao84 commented Feb 20, 2023

The nuget files are here: https://easyupload.io/m/sj1wvj (available for 7 days only). I think that's all you need and you hope you do not have other Firebase dependencies that conflict with them!

@webwarrior06
Copy link

Great. Thanks a lot!

@Picao84
Copy link

Picao84 commented Feb 20, 2023

Also, a note on building: Most of my troubles with build were related to using an M1 Mac. If you have access to an x86 Mac you should have less trouble building. Essentially I had to update Mac tools for versions that supported x86, plus I had to manually input a command to switch to x86 mode. Reason was that some dependencies the cake tool requires are not available for ARM. Only after that did the build work (and even then some projects did not fully build).

@Picao84
Copy link

Picao84 commented Feb 20, 2023

This was one of the steps: https://github.com/rbenv/rbenv

@webwarrior06
Copy link

I used that nuget and it solved one of my problems. But I would like to be on the latest version for many reasons.
Is it too hard to bind the latest Admob here? I followed MS xamarin library binding walkthrough. But, I am kinda lost. It is not seamless, and there are many failures. :(

@Picao84
Copy link

Picao84 commented Feb 20, 2023

I didn't really try yet and didn't have time since I fixed my issues.

@Picao84
Copy link

Picao84 commented Feb 20, 2023

The first thing would be to update the external dependencies. You can find the download urls inside the *.target files inside each project. I may try at some point to update them, refresh the externals folder and build. Although I expect problems to occur then lol.

@Picao84
Copy link

Picao84 commented Feb 22, 2023

Hi, I managed to update my AdMob to version 10, although I have not fully tested everything yet. The way I did it was creating a bindings library with xcframeworks (look at manual download here: https://developers.google.com/admob/ios/quick-start#update_your_infoplist). After that I copied the generated code from the obj folder in the Mobile Ads project (generated by previous build on the Mac). You still need to be able to build this project on the Mac though to get the generated code. After testing I will move to update Firebase Analytics and Crashlytics (I get conflicts with this project version installed and app does not build) and then I can share the projects on a separate repo for you to clone and build. After that you should only need to update the xcframework files and fix any changes on api definitions that may show up in the future. I'll get back here when done :)

@webwarrior06
Copy link

Oh. That’s awesome. I cloned the branch(Admob 9.2 branch where admob version is bound to 9.3. That worked in my app via local nuget installation. But, the issue is Adloader delegate is always null even though it is just set. I don’t know if the latest version helps out to solve the issue. You can see the issue I have raisen here. I will be waiting for your repo with 10.x. Thanks man for your interest! ☺️

@Picao84
Copy link

Picao84 commented Feb 22, 2023

So you were finally able to build the project? Then you can do that I said above to get V10. Regarding native and delegate, I fixed it by adding the missing delegate on API Definitions. When your app is running you should see on the console AdMob saying that the delegate doesn't have the expected parameters. You can find the existing delegates on API Definition file for MobileAds project, copy paste one of them and make the necessary changes (check Google Documentation / Source).

@Picao84
Copy link

Picao84 commented Feb 23, 2023

I've ran into loads of issues with Firebase for Analytics and Crashlytics though :( I can build the libraries fine but then my app will fail to build with 100+ linking errors. It doesn't help that some xcframeworks that the original project used don't seem to exist anymore in version 10. I'll let you know if I can fix it.

@webwarrior06
Copy link

Thanks! I have also experienced the same issue after adding the protocol you mentioned to the api definition. It is built fine in frameworks. But, it fails with the linking errors after I use it in my app.

@Picao84
Copy link

Picao84 commented Feb 23, 2023

I could update my app to use Mobile Ads 10, as it works 100% on its own, but I would lose Analytics and Crashlytics :( Will need up dedicate more time to this but won't really have it from next week as I'll start working with a new client (all this is for my own apps).

@Picao84
Copy link

Picao84 commented Feb 27, 2023

I have managed to solve some of the linking problems by adding the xcframeworks on my app project instead of the library projects and Firebase Analytics 10 working. Will try now the Crashlytics and Core.

@Picao84
Copy link

Picao84 commented Feb 27, 2023

There was also a fix for Swift dependencies that I got from here: xamarin/xamarin-macios#17179

@webwarrior06
Copy link

Great news. Looking forward to seeing it :)

@Picao84
Copy link

Picao84 commented Feb 27, 2023

It's all working fine now :) I still have to test if the DSYM file is being sent to Crashlytics on a Release build though!
Steps:
1 - Download Firebase from here: https://github.com/firebase/firebase-ios-sdk/releases/tag/10.0.0. Inside of the zip file there is a Readme that tells you what frameworks each project requires.
2 - Create a unified bindings library for each project (e.g. Firebase Analytics, Firebase Core, Firebase Crashlytics). Note that Firebase Core does not show up on the readme file as a separate project.
3 - Go to the GoogleApisForiOSComponents appropriate project (e.g. Firebase Analytics) and copy the contents of the obj/Release/xamarin.ios10/iOS to the library project (you can ignore source.list and dll / pdb files though).
4 - If the Messaging.g.cs under ObjRunTime class is named ApiDefinition change it to Enums to avoid conflicts.
5 - Check the .targets file on GoogleApisForiOSComponents appropriate project for keys used on tag to apply on csproj file.
7 - Inside the csproj of each library add the following:

<PropertyGroup>
<NoBindingEmbeeding>true<NoBindingEmbeeding>
</PropertyGroup>
8 - Reference the library projects on your Xamarin.iOS project

9 - Add the xcframework files the project requires to your Xamarin.iOS app project.
10 - Add this to your Xamarin.iOS app csproj file:

<Target Name="CreateMtouchExtraArgs" AfterTargets="_DetectSdkLocations">
        <PropertyGroup>
            <MtouchExtraArgs>$(MtouchExtraArgs) -v -v -v -v -gcc_flags "-L /usr/lib/swift -L $(_SdkDevPath)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/$(Platform)"</MtouchExtraArgs>
            <_BundlerArguments Condition="'$(_PlatformName)' != 'macOS'">$(MtouchExtraArgs)</_BundlerArguments>
        </PropertyGroup>
        <Message Importance="high" Text="MtouchExtraArgs is $(MtouchExtraArgs)" />
 </Target>

In regards to Google Mobile Ads, you can download the necessary files here, where it says manual download:
https://developers.google.com/admob/ios/quick-start

If you still have issues, the console might point you the right direction. If you have linking issues, googling the missing class usually helps you find the frawework missing, if any.

Good luck!

@Picao84
Copy link

Picao84 commented Feb 27, 2023

Comment updated!

@webwarrior06
Copy link

I'll try that out on the first occasion. Thanks for the great explanation!

@Picao84
Copy link

Picao84 commented Feb 27, 2023

By the way, do not forget to update the Output filename from NativeLibrary lol.. I did not initially and it was removing the reference everytime I was adding a new one haha.

@webwarrior06
Copy link

I think I did not understand fully your steps.
What I have tried so far:

  • Downloaded the [GoogleApisForiOSComponents]
  • Updated the library URL inside .csproj for Admob version to 10.5.0
  • Updated the versions for Firebase.Core and Admob in components.cake file to 10.5.0
  • Cake'd the "externals"
  • Cake'd the libs without errors
  • Referenced the new DLLs (Firebase.Core and mobileAds) into my project

During the build, I have encountered many native linking errors. Why could it be like that?

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants