import Foundation public struct CopyFilesTask { // MARK: Properties private let bundleService: BundleServicing private let fileService: FileServicing // MARK: Initialisers public init( bundleService: BundleServicing? = nil, fileService: FileServicing ) { self.bundleService = bundleService ?? Bundle.module self.fileService = fileService } // MARK: Functions public func callAsFunction(to rootFolder: URL) async throws (FileServiceError) { for file in File.allCases { guard let source = bundleService.url( forResource: file.rawValue, withExtension: nil, subdirectory: file.resourcePath ) else { assertionFailure("URL should have been initialized.") return } let destination = rootFolder.appendingPath(file.filePath) try await fileService.copyFile(from: source, to: destination) } } }