I'm on macOS Monterey (12.0.1), not iOS, objective-c, XCode 13
I'm receiving this log message after building my app for arm64:
[general] *** -[NSKeyedUnarchiver validateAllowedClass:forKey:] allowed unarchiving safe plist type ''NSString' (0x1dcb1c848) [/System/Library/Frameworks/Foundation.framework]' for key 'NS.objects', even though it was not explicitly included in the client allowed classes set: '{(
"'NSDictionary' (0x1dcaee5d0) [/System/Library/Frameworks/CoreFoundation.framework]"
)}'. This will be disallowed in the future.
Any idea what's causing this and how to get rid of it?
Edit: it seems to happen with every app compiled on arm64 starting with macOS Monterey. So it might be a generic apple bug
CodePudding user response:
Thanks to @OI Sen it've had a closer look to the NSUnarchiver. First of all NSKeyedUnarchiver should be allocated and initialized like this:
NSError* err;
NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:someData error:&err];
In my specific case I use NSSecure coding. Therefore you have to specify classes on decoding objects. In my case it looked like this
NSDictionary* someDict = [unarchiver decodeObjectOfClass:[NSDictionary class] forKey:NSKeyedArchiveRootObjectKey];
But the NSDictionary contained additional strings. That was the cause of the log message. By adding NSString to the decoded class list the error is gone.
NSDictionary* someDict = [unarchiver decodeObjectOfClasses:[[NSSet alloc] initWithArray:@[[NSDictionary class],[NSString class]]] forKey:NSKeyedArchiveRootObjectKey];