I wanted to create migration from Transformable to String. I created mapping model and entity policy
class MigrationPolicy15to16: NSEntityMigrationPolicy {
@objc
func convertIntArrayToString(forValue: Any) -> String {
guard let array = forValue as? [Int] else { return "[]" }
return array.toJSONString()
}
}
FUNCTION($entityPolicy, "convertIntArrayToStringForValue:" , $source.categories)
It works, migration successes. But on some devices it doesn't happen. I found a device where this happens and found that tables inside DB model are empty. There no records in DB at all. But migration fails with following error:
CoreData: annotation: (migration) inferring mapping model failed with error: Error Domain=NSCocoaErrorDomain Code=134190 "(null)" UserInfo={entity=EntityName, property=categories, reason=Source and destination attribute types are incompatible} userInfo: {
entity = EntityName;
property = categories;
reason = "Source and destination attribute types are incompatible";
}