Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Mediation fails to initialize on iOS with an exception

Discussion in 'Unity Mediation' started by amjaliks, Apr 12, 2022.

  1. amjaliks

    amjaliks

    Joined:
    Jul 11, 2015
    Posts:
    149
    Just integrated Mediation SDK in our project. It works fine in Editor. Runs on Android. However, fails with an exception on iOS:

    NSInvalidArgumentException: +[UMISConfigurationResponse adNetworkFromAdNetworkName:]: unrecognized selector sent to class


    2022-04-12 02:41:27.289287+0300 PrimePeaks[24141:5332209] UnityMediationSdk with version 0.4.1 in use
    2022-04-12 02:41:27.292392+0300 PrimePeaks[24141:5332209] UMSReachability Flag Status: -R ------- networkStatusForFlags
    2022-04-12 02:41:27.693649+0300 PrimePeaks[24141:5332596] Attribution returned an error: Error Domain=ADClientErrorDomain Code=1 "The app is not authorized for ad tracking" UserInfo={NSLocalizedDescription=The app is not authorized for ad tracking}
    2022-04-12 02:41:27.718147+0300 PrimePeaks[24141:5332531] Unity Mediation diagnostics are Enabled
    2022-04-12 02:41:27.742884+0300 PrimePeaks[24141:5332531] Uncaught exception: NSInvalidArgumentException: +[UMISConfigurationResponse adNetworkFromAdNetworkName:]: unrecognized selector sent to class 0x10bd57e48
    (
    0 CoreFoundation 0x0000000181859110 E2F84645-2905-31EF-8EC7-3CC19C3CDDB3 + 626960
    1 libobjc.A.dylib 0x000000019a0a9d64 objc_exception_throw + 60
    2 CoreFoundation 0x0000000181935ff4 E2F84645-2905-31EF-8EC7-3CC19C3CDDB3 + 1531892
    3 CoreFoundation 0x00000001817ee524 E2F84645-2905-31EF-8EC7-3CC19C3CDDB3 + 189732
    4 CoreFoundation 0x00000001817ed660 _CF_forwarding_prep_0 + 96
    5 UnityFramework 0x000000010a83d0d8 -[UMSAdNetworkInitializationAdapterFactory getAdapterWithAdapterClass:] + 80
    6 UnityFramework 0x000000010a83abf4 -[UMSAdNetworkAdapterInitializationService initAdapter:installationId:adapterClass:] + 348
    7 UnityFramework 0x000000010a83a7b0 -[UMSAdNetworkAdapterInitializationService initializeAdNetworkAdaptersWithGameId:installationId:adapterClasses:] + 216
    8 UnityFramework 0x000000010a846c38 -[UMSInitializeRun initializeAdapters] + 480
    9 UnityFramework 0x000000010a846758 -[UMSInitializeRun initializationResponseHandlerWithResponse:error:] + 160
    10 UnityFramework 0x000000010a846628 __32-[UMSInitializeRun initializing]_block_invoke.47 + 60
    11 libdispatch.dylib 0x00000001814c9924 BD02A625-8475-3FD6-8DC3-8AED25D1573B + 10532
    12 libdispatch.dylib 0x00000001814cb670 BD02A625-8475-3FD6-8DC3-8AED25D1573B + 18032
    13 libdispatch.dylib 0x00000001814ce798 BD02A625-8475-3FD6-8DC3-8AED25D1573B + 30616
    14 libdispatch.dylib 0x00000001814dcde0 BD02A625-8475-3FD6-8DC3-8AED25D1573B + 89568
    15 libdispatch.dylib 0x00000001814dd608 BD02A625-8475-3FD6-8DC3-8AED25D1573B + 91656
    16 libsystem_pthread.dylib 0x00000001f22e70b8 _pthread_wqthread + 228
    17 libsystem_pthread.dylib 0x00000001f22e6e94 start_wqthread + 8
    )

    Unity 2020.3.33f1 (I have also tried .32f1)
    SDK 0.4.1 (tried 0.4.0 too)
    Xcode 13.3
     
  2. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    143
    Hi @amjaliks,

    Thanks for reaching out. Could you also share your Podfile and Podfile.lock from your generated iOS project?

    Thank you,
     
  3. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    143
    After a quick go at trying to reproduce your issue, I was quickly able to reproduce your issue. The most possible reason that this is occurring is because your target in Xcode doesn't have the '-ObjC' flag in the 'Other Linker Flags' section. In most cases that would be the UnityFramework target, and by default it should be there.

    My question to you is, are you changing the xcodeproj file via script post build by any chance? Or is there any way you know of that would be changing the values of 'Other Linker Flags' ?
     
  4. amjaliks

    amjaliks

    Joined:
    Jul 11, 2015
    Posts:
    149
    Thanks! Indeed UnityFramework is missing the
    -ObjC
    flag.

    Unfortunately, I can't find why this flag is missing from our iOS builds.

    From my attempts to understand what is going, this isn't related to .pbxproj modifications. This flag should come from .xcconfig file created by CocoaPods. At least this how works when I create a new empty Unity project and add Mediation package to it.
     
  5. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    143
    Thanks for providing further insight into this. Generally it is Cocoapods that includes that flag into UnityFrameworks, right. Which version of Cocoapods are you using? If possible, let us know if you find out what is causing this scenario in your project if you get to the bottom of it, I'll let you know if we are able to reproduce. Also, if you could share the Podfile of the generated Xcode project, that could help pinpoint the issue.

    Thanks!
     
  6. amjaliks

    amjaliks

    Joined:
    Jul 11, 2015
    Posts:
    149
    The issue went away after adding an AppLovin adapter, as its podspec includes
    -ObjC
    definition.
    Maybe the same should be done with a podspec for Unity Mediation SDK?
     
  7. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    143
    Hi @amjaliks,

    This is a known issue on certain Cocoapod versions, for example versions below 1.10.1. If you in fact do have such an older version, let us know if upgrading your Cocoapods version fixes the issue.

    Thanks for sharing this issue with us!
     
  8. amjaliks

    amjaliks

    Joined:
    Jul 11, 2015
    Posts:
    149
    Yes, indeed I have used and older version of CocoaPods 1.9.1.
    Updating to 1.11.3 seams to resolved the issue.

    I haven't done complete testing, however, a quick build of a Unity projects results in an Xcode project that has
    -ObjC
    flag set.
     
  9. DeclanMcPartlin

    DeclanMcPartlin

    Unity Technologies

    Joined:
    Nov 19, 2020
    Posts:
    143
    Thank you for confirm this with us @amjaliks, much appreciated.