'How to load file and run swift code from Swift Package Manager manifest file?
I have and iOS Project that has a SPM dependency and I am trying to update the Package object inside the SPM manifest file(Package.swift) based on a configuration file to get something similar to:
// Package.swift
// swift-tools-version:5.3
import PackageDescription
import Foundation
var modules : [Modules] = getConfigurationFrom("file.json")
// Where getConfigurationFrom function calls to:
// Bundle.main.path(forResource: "file", ofType: "json")
if modules.first.isEnabled {
// Build Package object with moduleA dependencies
Package(name: "Package", ... Dependencies for ModuleA ...)
} else {
// Build Package object with moduleB dependencies
Package(name: "Package", ... Dependencies for ModuleB ...)
}
But I am not able to properly load the json file from the Main bundle, maybe am I missing something here? Or is there another way to build different dependencies based on a file using SPM without using party libraries?
Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
