iosunity-game-engineunityads

UnityAds generated iOS project error


I'm using UnityAds for an iOS/Android game and when generating the Xcode project for iOS I get the following compiler errors related to UnityAdsWrapper.mm, a file generated by Unity

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:105:15: error: no known class method for selector 'sharedInstance'

                    [[UnityAds sharedInstance] setUnityVersion: UnityAdsCreateNSString(unityVersion)];

                               ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:105:31: error: no known instance method for selector 'setUnityVersion:'

                    [[UnityAds sharedInstance] setUnityVersion: UnityAdsCreateNSString(unityVersion)];

                                               ^~~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:126:18: error: no known class method for selector 'sharedInstance'

            if ([[UnityAds sharedInstance] canShowZone:zoneId])

                           ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:126:34: error: no known instance method for selector 'canShowZone:'

            if ([[UnityAds sharedInstance] canShowZone:zoneId])

                                           ^~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:130:16: error: no known class method for selector 'sharedInstance'

                            [[UnityAds sharedInstance] setZone:zoneId withRewardItem:rewardItemKey];

                                       ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:130:32: error: no known instance method for selector 'setZone:withRewardItem:'

                            [[UnityAds sharedInstance] setZone:zoneId withRewardItem:rewardItemKey];

                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:136:22: error: no known class method for selector 'sharedInstance'

                           [[UnityAds sharedInstance] setZone:zoneId];

                                      ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:136:38: error: no known instance method for selector 'setZone:'

                           [[UnityAds sharedInstance] setZone:zoneId];

                                                      ^~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:139:22: error: no known class method for selector 'sharedInstance'

                    return [[UnityAds sharedInstance] show:optionsDictionary];

                                      ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:139:43: error: cannot initialize a parameter of type 'UIViewController * _Nonnull' with an lvalue of type 'NSMutableDictionary *__strong'

                    return [[UnityAds sharedInstance] show:optionsDictionary];

                                                           ^~~~~~~~~~~~~~~~~

In file included from /ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:6:

In file included from /ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.h:10:

/ProjectDir/Builds/Build/UnityAds.framework/Headers/UnityAds.h:175:34: note: passing argument to parameter 'viewController' here

+ (void)show:(UIViewController *)viewController;

                             ^

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:146:21: error: no known class method for selector 'sharedInstance'

            return [[UnityAds sharedInstance] canShowZone:UnityAdsCreateNSString(rawZoneId)];

                              ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:146:37: error: no known instance method for selector 'canShowZone:'

            return [[UnityAds sharedInstance] canShowZone:UnityAdsCreateNSString(rawZoneId)];

                                              ^~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:151:14: error: no known class method for selector 'sharedInstance'

            [[UnityAds sharedInstance] setDebugMode:debugMode];

                       ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:156:14: error: no known class method for selector 'sharedInstance'

            [[UnityAds sharedInstance] setCampaignDataURL:UnityAdsCreateNSString(url)];

                       ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:156:30: error: no known instance method for selector 'setCampaignDataURL:'

            [[UnityAds sharedInstance] setCampaignDataURL:UnityAdsCreateNSString(url)];

                                       ^~~~~~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:45:14: error: no known class method for selector 'sharedInstance'

            [[UnityAds sharedInstance] setDelegate:self];

                       ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:46:14: error: no known class method for selector 'sharedInstance'

            [[UnityAds sharedInstance] setDebugMode:debugMode];

                       ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:47:14: error: no known class method for selector 'sharedInstance'

            [[UnityAds sharedInstance] setTestMode:testMode];

                       ^~~~~~~~~~~~~~

/ProjectDir/Builds/Build/Classes/UnityAds/UnityAdsUnityWrapper.mm:47:30: error: no known instance method for selector 'setTestMode:'

            [[UnityAds sharedInstance] setTestMode:testMode];

                                       ^~~~~~~~~~~

fatal error: too many errors emitted, stopping now [-ferror-limit=]

20 errors generated.

Anyone have a workaround or fix for this?


Solution

  • It looks like you have an old version of UnityAds - try the latest from the Asset Store.