From b4a6491db76cb1a3a11cb5bb15f0a0c02c2d93d2 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 6 Oct 2024 13:41:30 +0200 Subject: [PATCH] Implemented the "preview" constant for the ModelContainer+Constants extension in the app target. --- Piper.xcodeproj/project.pbxproj | 4 +-- .../Extensions/ModelContainer+Constants.swift | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift diff --git a/Piper.xcodeproj/project.pbxproj b/Piper.xcodeproj/project.pbxproj index 102f43f..fc590bd 100644 --- a/Piper.xcodeproj/project.pbxproj +++ b/Piper.xcodeproj/project.pbxproj @@ -429,7 +429,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Resources/Catalogs/Previews.xcassets"; + DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift Piper/Resources/Catalogs/Previews.xcassets"; DEVELOPMENT_TEAM = 7FMNM89WKG; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; @@ -461,7 +461,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Resources/Catalogs/Previews.xcassets"; + DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift Piper/Resources/Catalogs/Previews.xcassets"; DEVELOPMENT_TEAM = 7FMNM89WKG; ENABLE_HARDENED_RUNTIME = YES; ENABLE_PREVIEWS = YES; diff --git a/Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift b/Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift new file mode 100644 index 0000000..21d51a5 --- /dev/null +++ b/Piper/Sources/Previews/Extensions/ModelContainer+Constants.swift @@ -0,0 +1,26 @@ +// +// ModelContainer+Constants.swift +// Piper +// +// Created by Javier Cicchelli on 06/10/2024. +// Copyright © 2024 Röck+Cöde. All rights reserved. +// + +import SwiftData + +extension ModelContainer { + + // MARK: Constants + + static let preview: ModelContainer = { + do { + return try ModelContainer( + for: .entities, + configurations: ModelConfiguration(isStoredInMemoryOnly: true) + ) + } catch { + fatalError("Model Container should have been created.") + } + }() + +}