I'm trying to build an iOS AWS app and I'm having some problems.
I just updated Xcode to version 10.2 and created a brand new project. I'm at the point where I'm trying to install the dependencies with CocoaPods for user authentication. After modifying my podfile to include AWSMobileClient (and running pod install --repo-update
as the AWS documentation says) I get a build error in the AWSMobileClient.swift in this function:
@objc override public class func sharedInstance() -> AWSMobileClient {
return _sharedInstance
}
The error says this:
Cannot override a Self return type with a non-Self return type
I'm pretty darn stuck here and the only thing I can think to do at this point is to go back to Xcode 10.1.
Any help would be greatly appreciated.
As the error indicates, you need to return
Self
here if the class is not final.(This is assuming that
_sharedInstance
is of typeSelf
.)Alternately, you can modify the superclass not to return
Self
, and instead return a specific type (likely its own type).(All subclasses will in this case need to also return TheActualClass. I assume that class is AWSMobileClient.)
Since this is a framework, I would expect this to be fixed by the vendor, and I would make sure you're running the most up to date version of the framework.
Self
indicates that this method returns a value of the type of the class being called. So if you haveSomeClass.sharedInstance()
is must return aSomeClass
. But if you subclass that, then a call toSubClass.sharedInstance()
must return aSubClass
. If you can't achieve that, you're going to need to make something final, or not returnSelf
.This is a very strange override, however. It's not clear what this code is trying to achieve.