UnityAds generated iOS project error - ios

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?

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

Related

Flutter ios app not building with razorpay plugin

I was unable to build my flutter app in ios as I was getting these error, again and again, everything is working well for android.I get these error after using razorpay plugin in my app for integrating payment gateway.
Error output from Xcode build:
↳
BUILD FAILED *
Xcode's output:
↳
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:44:1: error: unknown attribute '_hasMissingDesignatedInitializers'
#_hasMissingDesignatedInitializers #objc public class PluginPaymentModel : ObjectiveC.NSObject {
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:51:41: error: unknown attribute '_hasMissingDesignatedInitializers'
#objc #_inheritsConvenienceInitializers #_hasMissingDesignatedInitializers public class Otpelf : ObjectiveC.NSObject {
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:51:7: error: unknown attribute '_inheritsConvenienceInitializers'
#objc #_inheritsConvenienceInitializers #_hasMissingDesignatedInitializers public class Otpelf : ObjectiveC.NSObject {
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:59:35: error: unknown attribute '_hasMissingDesignatedInitializers'
#_inheritsConvenienceInitializers #_hasMissingDesignatedInitializers #objc final public class RazorpayCheckout : ObjectiveC.NSObject {
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:59:1: error: unknown attribute '_inheritsConvenienceInitializers'
#_inheritsConvenienceInitializers #_hasMissingDesignatedInitializers #objc final public class RazorpayCheckout : ObjectiveC.NSObject {
^
/Users/ganpat/develop/flutter/.pub-cache/hosted/pub.dartlang.org/razorpay_flutter-1.2.2/ios/Classes/RazorpayDelegate.swift:2:8: error: failed to load module 'Razorpay'
import Razorpay
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:44:1: error: unknown attribute '_hasMissingDesignatedInitializers'
#_hasMissingDesignatedInitializers #objc public class PluginPaymentModel : ObjectiveC.NSObject {
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:51:41: error: unknown attribute '_hasMissingDesignatedInitializers'
#objc #_inheritsConvenienceInitializers #_hasMissingDesignatedInitializers public class Otpelf : ObjectiveC.NSObject {
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:51:7: error: unknown attribute '_inheritsConvenienceInitializers'
#objc #_inheritsConvenienceInitializers #_hasMissingDesignatedInitializers public class Otpelf : ObjectiveC.NSObject {
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:59:35: error: unknown attribute '_hasMissingDesignatedInitializers'
#_inheritsConvenienceInitializers #_hasMissingDesignatedInitializers #objc final public class RazorpayCheckout : ObjectiveC.NSObject {
^
/Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/razorpay-pod/Pod/Razorpay.framework/Modules/Razorpay.swiftmodule/x86_64-apple-ios-simulator.swiftinterface:59:1: error: unknown attribute '_inheritsConvenienceInitializers'
#_inheritsConvenienceInitializers #_hasMissingDesignatedInitializers #objc final public class RazorpayCheckout : ObjectiveC.NSObject {
^
/Users/ganpat/develop/flutter/.pub-cache/hosted/pub.dartlang.org/razorpay_flutter-1.2.2/ios/Classes/RazorpayDelegate.swift:2:8: error: failed to load module 'Razorpay'
import Razorpay
^
Command CompileSwift failed with a nonzero exit code
/Users/ganpat/develop/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-4.4.0/ios/Classes/strategies/NotificationPermissionStrategy.m:71:5: warning: 'UIRemoteNotificationType' is deprecated: first deprecated in iOS 8.0 - Use UserNotifications Framework's UNAuthorizationOptions for user notifications and registerForRemoteNotifications for receiving remote notifications instead. [-Wdeprecated-declarations]
UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
^
In module 'UIKit' imported from /Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/Target Support Files/permission_handler/permission_handler-prefix.pch:2:
/Users/ganpat/Desktop/Xcode 2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:69:32: note: 'UIRemoteNotificationType' has been explicitly marked deprecated here
typedef NS_OPTIONS(NSUInteger, UIRemoteNotificationType) {
^
/Users/ganpat/develop/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-4.4.0/ios/Classes/strategies/NotificationPermissionStrategy.m:71:72: warning: 'enabledRemoteNotificationTypes' is deprecated: first deprecated in iOS 8.0 - Use -[UIApplication isRegisteredForRemoteNotifications] and UserNotifications Framework's -[UNUserNotificationCenter getNotificationSettingsWithCompletionHandler:] to retrieve user-enabled remote notification and user notification settings [-Wdeprecated-declarations]
UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
^
In module 'UIKit' imported from /Users/ganpat/Desktop/Flutter_Apps_Projects_2021/wsflutter/ios/Pods/Target Support Files/permission_handler/permission_handler-prefix.pch:2:
/Users/ganpat/Desktop/Xcode 2.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:229:1: note: 'enabledRemoteNotificationTypes' has been explicitly marked deprecated here
(UIRemoteNotificationType)enabledRemoteNotificationTypes API_DEPRECATED("Use -[UIApplication isRegisteredForRemoteNotifications] and UserNotifications Framework's -[UNUserNotificationCenter getNotificationSettingsWithCompletionHandler:] to retrieve user-enabled remote notification and user notification settings", ios(3.0, 8.0)) API_UNAVAILABLE(tvos);
^
2 warnings generated.
note: Using new build system
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone 11 Pro Max

Null passed to a callee that requires a non-null argument, but I haven't set anything nonnull

I have this simple code:
-(NSArray< UserObject *> *)loginUsers {
return [self loginUsersForSite:nil];//Null passed to a callee that requires a non-null argument
}
-(NSArray<UserObject *> *)loginUsersForSite:(UserDBO*)aa {
}
Why do I get the "Null passed to a callee that requires a non-null argument" there? There is no nonnull here!!! What is going on?
I tried setting the parameter to (nullable UserDBO*) but then I get "Nullability specifier 'nullable' conflicts with existing specifier 'nonnull'" . I don't unederstand where the nonnull existing specifier is... This class inherits from NSObject, implements no protocol. There is no "nonnull" in the .h file
In the .h file the class was set to assume non null
NS_ASSUME_NONNULL_BEGIN
This is what caused the problem

CLANG: Elaborated type refers to a typedef error

Here is my code snippet
template <class T>
struct ClassFriendMaker
{
typedef T Type;
};
template <class T>
class Singleton
{
friend class ClassFriendMaker<T>::Type; // Problem in this line
//Other declaration
}
When compiled with CLANG, it gave me an error:
error: elaborated type refers to a typedef
friend class ClassFriendMaker<T>::Type;
^
May I know what's wrong ? Thankyou
Replace class with typename in friend declaration
friend class ClassFriendMaker<T>::Type;
friend typename ClassFriendMaker<T>::Type;

Handle swift throw in closure in objective-c

I've an objective-c function that looks like below
+ (void) invokeSortingWithClassName: (NSString*) className functionName: (NSString*) functionName closure: (id(^)(NSArray* arr))closure;
and I've to call this method from a swift class. The swift code that calls this method looks like below
SortHandler.invokeSorting(withClassName: className, functionName: functionName, closure:
{
args in
let something = unwrap(args!)
do
{
let returnValue = try closure(something as NSArray!) //this is another closure coming as a parameter in the function in which this code is written and this throws
return returnValue;
}
catch
{
throw error
}
return "-1" as! T
})
At the start of closure definition, I get this attached error
Essentially, this closure throws an error and I am not sure, how to handle this error in objective-c definition of this function. Please help me fix this error
While a closure can be declared with throws, this closure has not been declared with throws, so your closure cannot throw - this is exactly what the error message is telling you.
Since the function is declared in Objective-C, the function signature can't be changed to include throws as Objective-C doesn't know anything about Swift exceptions.
The standard way in which error handling is translated between Swift and Objective-C is for the Objective-C block to receive an &NSError parameter.
If you have the ability to change the Objective-C method signature, it should be declared as
+(void) invokeSortingWithClassName: (NSString* _Nullable) className functionName: (NSString* _Nullable) functionName closure: (id _Nullable (^_Nullable)(NSArray* _Nullable arr, NSError* _Nullable * _Nullable error))closure;
This will allow you to throw from swift with the error being received via the error parameter in Objctive-C.
If you cannot change the method signature, then you will need to catch the exception in your closure and simply return an 'error' value, such as nil

Find Argument Class / Type From Selector Variable - Objective-C

I'm working on a class that involves sending a selector as a variable to be used later. The selector is required to take one argument, a BOOL value. Executed like so:
IMP imp = [ob methodForSelector:selector];
void (*func)(id, SEL, BOOL) = (void *)imp;
func(ob, selector, YES);
If someone tries to set a selector with a variable that doesn't match a BOOL, I'd like to return an error. Is there a way, when receiving the selector that I can check whether or not its argument is a BOOL, or in general, what Class or Type of argument has been passed?
Why?
I'm setting up a quasi notification center in one of my classes so I can easily add observers and have more control over information distribution.
Look at the method signature:
NSMethodSignature * sig = [ob methodSignatureForSelector:selector];
NSAssert(0 == strcmp(#encode(BOOL), [sig getArgumentTypeAtIndex:2]),
#"Method must take a BOOL as its sole argument.");

Resources