Implemented the "samples(in: )" static function for the Repository+Samples extension in the app target.

This commit is contained in:
Javier Cicchelli 2024-10-06 13:35:03 +02:00
parent 0d43a148db
commit cd9bd975b4
2 changed files with 38 additions and 2 deletions

View File

@ -429,7 +429,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = Piper/Resources/Catalogs/Previews.xcassets;
DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.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/Resources/Catalogs/Previews.xcassets;
DEVELOPMENT_ASSET_PATHS = "Piper/Sources/Previews/Extensions/Repository+Samples.swift Piper/Resources/Catalogs/Previews.xcassets";
DEVELOPMENT_TEAM = 7FMNM89WKG;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;

View File

@ -0,0 +1,36 @@
//
// Repository+Samples.swift
// Piper
//
// Created by Javier Cicchelli on 06/10/2024.
// Copyright © 2024 Röck+Cöde. All rights reserved.
//
import Foundation
import SwiftData
extension Repository {
// MARK: Functions
@MainActor
static func samples(in container: ModelContainer) {
let context = container.mainContext
context.insert(Repository(
URL(filePath: "/full/path/to/repository/name-0.git"),
sortOrder: 0
))
context.insert(Repository(
URL(filePath: "/full/path/to/repository/name-1.git"),
sortOrder: 1
))
context.insert(Repository(
URL(filePath: "/full/path/to/repository/name-2.git"),
sortOrder: 2
))
}
}