Error with Xcode 10 #231

Closed
opened 2025-12-29 15:27:01 +01:00 by adam · 1 comment
Owner

Originally created by @felipekoblinger on GitHub (Sep 20, 2018).

Hello! I'm not sure if I'm doing something wrong.

I'm using CoreStore (latest - 5.3.0) in a simple project and it was working fine on Xcode 9.4.1, but it is giving a runtime error in Xcode 10 (iOS 12).

❗ [CoreStore: Assertion Failure] Value.swift:140 value
  ↪︎ Attempted to access values from a 'MovieEntity' meta object. Meta objects are only used for querying keyPaths and infering types.

Code base: https://github.com/felipekoblinger/ibd185-my-watched-movies-ios

It is working fine in iOS 12 with Xcode 9.4.1.

Am I missing something?

Thanks :)

Originally created by @felipekoblinger on GitHub (Sep 20, 2018). Hello! I'm not sure if I'm doing something wrong. I'm using CoreStore (latest - 5.3.0) in a simple project and it was working fine on Xcode 9.4.1, but it is giving a runtime error in Xcode 10 (iOS 12). ``` ❗ [CoreStore: Assertion Failure] Value.swift:140 value ↪︎ Attempted to access values from a 'MovieEntity' meta object. Meta objects are only used for querying keyPaths and infering types. ``` Code base: https://github.com/felipekoblinger/ibd185-my-watched-movies-ios It is working fine in iOS 12 with Xcode 9.4.1. Am I missing something? Thanks :)
adam added the fixedcorestore bugdiscussion labels 2025-12-29 15:27:02 +01:00
adam closed this issue 2025-12-29 15:27:02 +01:00
Author
Owner

@JohnEstropia commented on GitHub (Sep 21, 2018):

@felipekoblinger Hi, this was a known issue with Swift 4.2 and should be fixed in the develop branch for version 5.3.1. (I'm pushing the Cocoapods version within the day)

This is due to the changes in memory ownership model in Swift 4.2. In particular, in places where objects are chained:

let friendName = person.friends.value?.first?.name.value

In this case the array returned from the friends relationship may be deallocated before the name property is read. You can fix this in the current 5.3.0 version by doing

let friendName = withExtendedLifetime(person.friends.value) { $0?.first?.name.value }

In CoreStore 5.3.1 all CoreStoreObject property types now keep a strong reference to the internal NSManagedObject. In theory this shouldn't cause retain cycles because NSManagedObjects don't retain their parent CoreStoreObjects and their properties.

I'm keeping this issue open to get feedback from others. Let me know if you observe anything unstable.

@JohnEstropia commented on GitHub (Sep 21, 2018): @felipekoblinger Hi, this was a known issue with Swift 4.2 and should be fixed in the `develop` branch for version 5.3.1. (I'm pushing the Cocoapods version within the day) This is due to the [changes in memory ownership model](https://github.com/apple/swift/blob/master/docs/OwnershipManifesto.md) in Swift 4.2. In particular, in places where objects are chained: ```swift let friendName = person.friends.value?.first?.name.value ``` In this case the array returned from the `friends` relationship may be deallocated before the `name` property is read. You can fix this in the current `5.3.0` version by doing ```swift let friendName = withExtendedLifetime(person.friends.value) { $0?.first?.name.value } ``` In CoreStore 5.3.1 all CoreStoreObject property types now keep a strong reference to the internal `NSManagedObject`. In theory this shouldn't cause retain cycles because `NSManagedObject`s don't retain their parent `CoreStoreObject`s and their properties. I'm keeping this issue open to get feedback from others. Let me know if you observe anything unstable.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore#231