Compiler error with XCode beta6 in swift3_2 branch #164

Closed
opened 2025-12-29 15:26:00 +01:00 by adam · 3 comments
Owner

Originally created by @laeroah on GitHub (Aug 23, 2017).

screen shot 2017-08-23 at 3 05 28 pm

NSManagedObjectModel constructor convenience init?(contentsOf url: URL) returns an optional value but the function is expecting a nonoptional value.
It seems that Xcode9 beta5 wasn't picking up this error for some reason. Xcode8 compiler will complain as expected.

Looks like the old version had the unwrapping, but was removed in new version:

    public func rawModel() -> NSManagedObjectModel {
    
        if let cachedRawModel = self.cachedRawModel {
            
            return cachedRawModel
        }
        if let rawModel = NSManagedObjectModel(contentsOf: self.modelVersionFileURL) {
            
            self.cachedRawModel = rawModel
            return rawModel
        }
        CoreStore.abort("Could not create an \(cs_typeName(NSManagedObjectModel.self)) from the model at URL \"\(self.modelVersionFileURL)\".")
    }
Originally created by @laeroah on GitHub (Aug 23, 2017). <img width="1247" alt="screen shot 2017-08-23 at 3 05 28 pm" src="https://user-images.githubusercontent.com/1928509/29634088-a12b9408-8816-11e7-8567-17850c141a99.png"> `NSManagedObjectModel` constructor `convenience init?(contentsOf url: URL)` returns an optional value but the function is expecting a nonoptional value. It seems that Xcode9 beta5 wasn't picking up this error for some reason. Xcode8 compiler will complain as expected. Looks like the old version had the unwrapping, but was removed in new version: ``` public func rawModel() -> NSManagedObjectModel { if let cachedRawModel = self.cachedRawModel { return cachedRawModel } if let rawModel = NSManagedObjectModel(contentsOf: self.modelVersionFileURL) { self.cachedRawModel = rawModel return rawModel } CoreStore.abort("Could not create an \(cs_typeName(NSManagedObjectModel.self)) from the model at URL \"\(self.modelVersionFileURL)\".") } ```
adam closed this issue 2025-12-29 15:26:00 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Aug 24, 2017):

Ah, I fixed this in the Swift 4 branch completely misunderstanding this was a Swift 4 change and not an iOS 11 change. Sorry about that. Will push the fix for the 3.2 branch as well.

@JohnEstropia commented on GitHub (Aug 24, 2017): Ah, I fixed this in the Swift 4 branch completely misunderstanding this was a Swift 4 change and not an iOS 11 change. Sorry about that. Will push the fix for the 3.2 branch as well.
Author
Owner

@laeroah commented on GitHub (Aug 24, 2017):

Thanks!

@laeroah commented on GitHub (Aug 24, 2017): Thanks!
Author
Owner

@JohnEstropia commented on GitHub (Aug 24, 2017):

Fixed in the prototype/Swift_3_2 branch as well. Thanks!

@JohnEstropia commented on GitHub (Aug 24, 2017): Fixed in the `prototype/Swift_3_2` branch as well. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#164