I have written a new Core-Data app with a Header and Detail record. It was working fine until I added a Transformer. Now the App shuts down on launch, closing the debugger in Xcode when it does this, and previews are not working - giving me the error - Error Domain=FBProcessExit Code=1 โThe process exited voluntarily.โ UserInfo={BSErrorCodeDescription=voluntary, NSLocalizedFailureReason=The process exited voluntarily.} on all views in the app. Can anyone help me figure out how to debug this?
I am including the model code and the transformer in case this helps:
import Foundation
import CoreData
import UIKit
extension Event {
@nonobjc public class func fetchRequest() -> NSFetchRequest<Event> {
return NSFetchRequest<Event>(entityName: "Event")
}
@NSManaged public var cardFrontImage: UIImage?
@NSManaged public var event: String?
@NSManaged public var recipient: Recipient?
}
extension Event : Identifiable {
}
Tranformer code:
import Foundation
import UIKit
class ImageTransformer: ValueTransformer {
override class func transformedValueClass() -> AnyClass {
return NSData.self
}
override class func allowsReverseTransformation() -> Bool {
return true
}
override func reverseTransformedValue(_ value: Any?) -> Any? {
autoreleasepool{
guard let data = value as? Data else {
return nil
}
return UIImage(data: data)
}
}
override func transformedValue(_ value: Any?) -> Any? {
autoreleasepool{
guard let image = value as? UIImage else {
return nil
}
return image.jpegData(compressionQuality: 1.0)
}
}
}
and where I load the transformer:
@main
struct CardApp: App {
@Environment(\.scenePhase) private var scenePhase
let context = PersistentCloudKitContainer.persistentContainer.viewContext
static let doInitialize: Void = {
ValueTransformer.setValueTransformer(ImageTransformer(), forName: NSValueTransformerName("ImageTransformer"))
// register transformers here
}()
static func main() {
CardApp.doInitialize
}
var body: some Scene {
// CODE
}
}