Parse-sdk-ios-osx: Type 'MyClass' does not conform to protocol 'PFSubclassing'

Created on 16 Aug 2017  路  15Comments  路  Source: parse-community/Parse-SDK-iOS-OSX

With the latest Version of XCode 9b5 and the Parse SDK 1.15.1 I can not subclass anymore. Any idea what might be wrong?

The error is:
Type 'Location' does not conform to protocol 'PFSubclassing'

import Foundation
import Parse

class Location: PFObject {
    static public let entityName = "Location"

    @NSManaged var name: String
    @NSManaged var country: String
    @NSManaged var timezone: String
    @NSManaged var latitude: Double
    @NSManaged var longitude: Double

    func update(source: PFObject, successHandler: @escaping () -> Void, errorHandler: @escaping () -> Void) {
        objectId = source.objectId
        name = source["name"] as! String
        country = source["country"] as! String
        latitude = source["latitude"] as! Double
        longitude = source["longitude"] as! Double
        timezone = source["timezone"] as! String

        successHandler()
    }
}

extension Location: PFSubclassing {

    static func parseClassName() -> String {
        return entityName
    }
}

Most helpful comment

To be sure I deleted the extension and implemented it like you with the same result.
I solved it now by going back to Swift 3.2 - here it is working. So it is an issue with Swift 4.

All 15 comments

what's the suggested fix?

@ogezue we have it declared this way in our project:

class Location: PFObject, PFSubclassing {
    static public let entityName = "Location"
    static func parseClassName() -> String {
        return entityName
    }
...
}

Does it work for you?

To be sure I deleted the extension and implemented it like you with the same result.
I solved it now by going back to Swift 3.2 - here it is working. So it is an issue with Swift 4.

Ok, we鈥檒l try to figure out something, in the meantime, you can probably file a radar as it seems to be a regression / side effect on the latest swift builds.

I have the same issue and had to revert back to swift 3.2 - Please let me know if you find a way to fix this.

DID you try 1.15.2?

@flovilmart Yes I am using Parse SDK 1.15.2 and Xcode 9 GM - The error is the same as ogezue. Type 'PICTURE' does not conform to protocol 'PFSubclassing'

EDIT: By cleaning the build folder and retyping each of my class extensions start "extension PICTURE: PFSubclassing {" it worked.

So that鈥檚 good then.

@laurentfarci I'm having this problem too, but I'm not following what your solution was. Can you go into more detail?

The Problem solves with XCode9 GM. Just clean your cache.

@craiggrummitt Make sure you are using Parse SDK 1.15.2 and Xcode 9 GM. Clean your build folder in Xcode - and then for my part I had to rewrite the start of my class extensions start i.e "extension PICTURE: PFSubclassing {"

@laurentfarci thanks for the tips, I have the latest Xcode 9 GM, but quite possibly Parse needs updating, will check that. I had trouble understanding your last suggestion however: how was that extension declaration different to the extension declaration you had previously?

@craiggrummitt You are welcome. There was no difference for the declaration, somehow Xcode was still showing me the error and by re-typing the declaration with auto-complete it made the error message disappear.

@laurentfarci Ha! OK, thanks for clarifying.

I was having this same issue. I just updated the new Parse and Bolts SDK and everything works well on swift 4

Was this page helpful?
0 / 5 - 0 ratings