Xcode 12: How to fix the error 'archiveRootObject:toFile:' is deprecated

Viewed 1985

I am using a beta of Xcode 12 (Version 12.0 beta (12A6159)). My project uses Firebase. When I try to build it, some errors appears, like this one :

'archiveRootObject:toFile:' is deprecated: first deprecated in iOS 12.0 - Use +archivedDataWithRootObject:requiringSecureCoding:error: and -writeToURL:options:error: instead

Xcode tells me to fix this problem in the folder "GoogleDataTransport", in a file at this line:

[NSKeyedArchiver archiveRootObject:self toFile:[GDTCORStorage archivePath]];

I tried to follow stupidly what the error message tells me to do, so I started to write what the error says. I taped:

[NSKeyedArchiver archivedDataWithRootObject:<#(nonnull id)#> requiringSecureCoding:<#(BOOL)#> error:<#(NSError *__autoreleasing  _Nullable * _Nullable)#>];

I have no idea what I'm supposed to write to complete the blanks. Would anyone have any idea?

1 Answers

Even if we update the Firebase SDK to the latest version, errors still appear (with Xcode 12 beta (12A6159)). I reported this issue to Firebase Support. They told me it looks like a problem with CocoaPods. However, they gave me a workaround.

I will update this post when I have more informations.

Related