Why am I getting Property with 'retain (or strong)' attribute must be of object type in GCDevice.h?

Viewed 1771

My code has always compiled correctly in Xcode versions prior to 12. Now that I'm trying to build in 12 I'm getting this error - which I know how to fix, except that it's in the CoreController header, GCDevice.h, provided by Apple. Doubly annoyingly, I'm not even using CoreController - but it's imported by GameKit.h, which I do use. My code is written in ObjectiveC, and built for MacOS, and GameKit is imported as follows (if that makes any difference):

#import <Cocoa/Cocoa.h>
#import <GameKit/GameKit.h>
#import <AVFoundation/AVAudioPlayer.h>

When I create a completely new project, with GameKit and with only my code which uses GameKit copied and pasted into it (so not the actual game), it builds fine. Which, to my mind, suggests maybe a problem with the build settings?

GameKit is only imported once, so I don't think that there's a problem with multiple imports. Has anyone else seen this issue?

3 Answers

enter image description here

build Settings -> Depolyment -> macOS Depolyment Target -> 11.1

In my case, the answer was that there was nothing amiss with the code. For some reason the contents of the .xcodeproj file were corrupted, or different from what Xcode 12 expected, but in a way that Xcode 12 couldn't repair. Once I cleaned out the xcuserdata from the .xcodeproj (open the xcodeproj bundle and delete xcuserdata (also from the xcworkspace bundle)), the problem disappeared.

Your mileage may vary - make sure that you have a backup before messing around in this file!

For those wanting to use an earlier Deployment version, you can (as Ma Jin answered) set the Deployment Target to 11.1 to remove the error. But then, after doing a compile, you can set the Deployment version back to the earlier version (e.g. 10.9) and it will compile also. Don't ask me why this works.

Related