CosmicMind / Graph

Graph is a semantic database that is used to create data-driven applications.
http://cosmicmind.com
MIT License
873 stars 72 forks source link

ManagedNode.swift - breaking change using XCode 10.2 Swift 5 Compiler #160

Closed muzoman closed 5 years ago

muzoman commented 5 years ago

I've set SWIFT_VERSION to 4.2 for the Graph pod but when compiling my workspace I get the following error in ManagedNode.swift line 55: Incorrect argument label in call (have 'stringInterpolationSegment:', expected '_cocoaString:')

The code in question is below. Apple documentation indicates that String(stringInterpolationSegment: should not be called directly. I tried amending the parameter as the error suggested but that just caused a runtime crash. I'm not clear what this code is trying to achieve exactly so can't recommend how to fix it. There's obviously something subtle going on as otherwise why not just use "(self.nodeClass)" instead? ( I tried changing the code to that too but caused runtime crash too).


        guard let moc = managedObjectContext else {
            fatalError("[Graph Error: Cannot obtain permanent objectID]")
        }

        var result: String?
        moc.performAndWait { [unowned self, unowned moc] in
            do {
                try moc.obtainPermanentIDs(for: [self])
            } catch let e as NSError {
                fatalError("[Graph Error: Cannot obtain permanent objectID - \(e.localizedDescription)]")
            }
            result = String(stringInterpolationSegment: self.nodeClass) + self.type + self.objectID.uriRepresentation().lastPathComponent
        }
        return result!
    }
OrkhanAlikhanov commented 5 years ago

Just use "\(self.nodeClass)" instead. It passes tests on swift 4.2. Haven't installed swift 5 yet.

OrkhanAlikhanov commented 5 years ago

Hey @muzoman! I've tested the change, it passes all. See #162

daniel-jonathan commented 5 years ago

This is in development. Thanks guys!