googleads / googleads-mobile-unity

Official Unity Plugin for the Google Mobile Ads SDK
https://developers.google.com/admob/unity
Apache License 2.0
1.38k stars 1.08k forks source link

crash on startup library not loaded #3515

Open RomainBitard opened 3 months ago

RomainBitard commented 3 months ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

When I add applovin and build the app crash on startup, it works without any adapter

2024-08-12 11:09:38.046306+0200 crapette[715:18860] Error loading /var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/UnityFramework.framework/UnityFramework:  dlopen(/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: '@rpath/AppLovinSDK.framework/AppLovinSDK'
  Referenced from: '/private/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/UnityFramework.framework/UnityFramework'
  Reason: tried: '/usr/lib/swift/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/usr/lib/swift/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/System/Library/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file)
2024-08-12 11:09:38.048903+0200 crapette[715:18860] Error loading /var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/UnityFramework.framework/UnityFramework:  dlopen(/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: '@rpath/AppLovinSDK.framework/AppLovinSDK'
  Referenced from: '/private/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/UnityFramework.framework/UnityFramework'
  Reason: tried: '/usr/lib/swift/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/usr/lib/swift/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/9529AEE7-3187-4461-9613-C8A10238E4A3/crapette.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/System/Library/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file)
RomainBitard commented 3 months ago

Tried the same process with unity, it works

RomainBitard commented 3 months ago

I'll try a lower version of applovin adapter

RomainBitard commented 3 months ago

same problem Library not loaded: '@rpath/AppLovinSDK.framework/AppLovinSDK

each time I update admob I have tons of issues, admob sdk is f****ng TRASH

RomainBitard commented 3 months ago

I have to find the xcframework file and manually copy it with a postprocessbuild ... basically I have to do your job to make it work . it's amazing. I'll probably switch to a competitor soon I can't lose my time like this every update

using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using UnityEngine;
namespace unscripted._Scripts.Editor {
    public class ApplovinTMP
    {

        [PostProcessBuild]
        public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProject)
        {
            if (target == BuildTarget.iOS)
            {
                string projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
                PBXProject proj = new PBXProject();
                proj.ReadFromFile(projPath);

                string mainTargetGuid = proj.GetUnityMainTargetGuid();

                // Adding xcframework
                string xcFrameworkPath = "Pods/GoogleMobileAdsMediationAppLovin/AppLovinAdapter-12.4.0.0/AppLovinAdapter.xcframework";
                string fileGuid = proj.AddFile(xcFrameworkPath, xcFrameworkPath, PBXSourceTree.Source);
                proj.AddFileToBuild(mainTargetGuid, fileGuid);

                // Ensure frameworks are embedded properly
                string embedFrameworksBuildPhase = proj.GetFrameworksBuildPhaseByTarget(mainTargetGuid);
                proj.AddFileToBuildSection(mainTargetGuid, embedFrameworksBuildPhase, fileGuid);

                proj.SetBuildProperty(mainTargetGuid, "LD_RUNPATH_SEARCH_PATHS", "$(inherited) @executable_path/Frameworks");

                proj.WriteToFile(projPath);
            }
        }
    }
}
RomainBitard commented 3 months ago

it doesn't even work on the latest adapter version it works on applovin7.2.0

RomainBitard commented 3 months ago

I have the same problem with inMobi @NVentimiglia do you know what causes this ?

RomainBitard commented 3 months ago

The problem is known since a long time already https://github.com/googleads/googleads-mobile-unity/issues/3395

NVentimiglia commented 1 month ago

We are looking into this issue and will get back to you when we have updates.

NVentimiglia commented 3 days ago

image

for AppLovin you must set the External Dependency Manager > iOS > Settings to use a dynamic linked framework