ModulesGraph
A collection of packages.
struct ModulesGraphA collection of packages.
struct ModulesGraphimport PackageGraphinit(rootPackages: [ResolvedPackage], rootDependencies: [ResolvedPackage] = [], packages: IdentifiableSet<ResolvedPackage>, dependencies requiredDependencies: [PackageReference], binaryArtifacts: [PackageIdentity : [String : BinaryArtifact]]) throws Construct a package graph directly.
static func load(root: PackageGraphRoot, identityResolver: any IdentityResolver, additionalFileRules: [FileRuleDescription] = [], externalManifests: OrderedDictionary<PackageIdentity, (manifest: Manifest, fs: any FileSystem)>, requiredDependencies: [PackageReference] = [], unsafeAllowedPackages: Set<PackageReference> = [], binaryArtifacts: [PackageIdentity : [String : BinaryArtifact]], prebuilts: [PackageIdentity : [String : PrebuiltLibrary]], shouldCreateMultipleTestProducts: Bool = false, createREPLProduct: Bool = false, customPlatformsRegistry: PlatformRegistry? = .none, customXCTestMinimumDeploymentTargets: [Platform : PlatformVersion]? = .none, testEntryPointPath: AbsolutePath? = nil, fileSystem: any FileSystem, observabilityScope: ObservabilityScope, productsFilter: ((Product) -> Bool)? = nil, modulesFilter: ((Module) -> Bool)? = nil) throws -> ModulesGraph Load the package graph for the given package path.
static func load(root: PackageGraphRoot, identityResolver: any IdentityResolver, additionalFileRules: [FileRuleDescription] = [], externalManifests: OrderedDictionary<PackageIdentity, (manifest: Manifest, fs: any FileSystem)>, requiredDependencies: [PackageReference] = [], unsafeAllowedPackages: Set<PackageReference> = [], binaryArtifacts: [PackageIdentity : [String : BinaryArtifact]], prebuilts: [PackageIdentity : [String : PrebuiltLibrary]], shouldCreateMultipleTestProducts: Bool = false, createREPLProduct: Bool = false, traitConfiguration: TraitConfiguration? = nil, customPlatformsRegistry: PlatformRegistry? = .none, customXCTestMinimumDeploymentTargets: [Platform : PlatformVersion]? = .none, testEntryPointPath: AbsolutePath? = nil, fileSystem: any FileSystem, observabilityScope: ObservabilityScope, productsFilter: ((Product) -> Bool)? = nil, modulesFilter: ((Module) -> Bool)? = nil) throws -> ModulesGraph Load the package graph for the given package path.
var allModules: IdentifiableSet<ResolvedModule> { get }Returns all the modules in the graph, regardless if they are reachable from the root modules or not.
var allProducts: IdentifiableSet<ResolvedProduct> { get }Returns all the products in the graph, regardless if they are reachable from the root modules or not.
let binaryArtifacts: [PackageIdentity : [String : BinaryArtifact]]Any binary artifacts referenced by the graph.
let inputPackages: [ResolvedPackage]All root and root dependency packages provided as input to the graph.
let packages: IdentifiableSet<ResolvedPackage>The complete set of contained packages.
var reachableModules: IdentifiableSet<ResolvedModule> { get }The list of all modules reachable from root modules.
var reachableProducts: IdentifiableSet<ResolvedProduct> { get }The list of all products reachable from root modules.
let requiredDependencies: [PackageReference]Package dependencies required for a fully resolved graph.
let rootPackages: IdentifiableSet<ResolvedPackage>The root packages.
func computeTestModulesForExecutableModules() throws -> [ResolvedModule.ID : [ResolvedModule]] Computes a map from each executable module in any of the root packages to the corresponding test modules.
func directDependencies(for package: ResolvedPackage) -> [ResolvedPackage] Returns all of the packages that the given package depends on directly.
func isInRootPackages(_ module: ResolvedModule, satisfying buildEnvironment: BuildEnvironment) -> Bool Returns true if a given module is present in root packages and is not excluded for the given build environment.
func isRootPackage(_ package: ResolvedPackage) -> Bool func module(for name: String) -> ResolvedModule? Find a module given a name and an optional destination. If a destination is not specified this method uses .destination and falls back to .tools for macros, plugins, and tests.
func package(for identity: PackageIdentity) -> ResolvedPackage? Returns the package based on the given identity, or nil if the package isn’t in the graph.
func package(for module: ResolvedModule) -> ResolvedPackage? Returns the package that contains the module, or nil if the module isn’t in the graph.
func package(for product: ResolvedProduct) -> ResolvedPackage? Returns the package that contains the product, or nil if the product isn’t in the graph.
func product(for name: String) -> ResolvedProduct? Find a product given a name and an optional destination. If a destination is not specified this method uses .destination and falls back to .tools for macros, plugins, and tests.
var allTargets: IdentifiableSet<ResolvedModule> { get }var reachableTargets: IdentifiableSet<ResolvedModule> { get }func computeTestTargetsForExecutableTargets() throws -> [ResolvedModule.ID : [ResolvedModule]] func target(for name: String) -> ResolvedModule? import SPMBuildCorestatic func computePluginGeneratedFiles(target: ResolvedModule, toolsVersion: ToolsVersion, additionalFileRules: [FileRuleDescription], buildParameters: BuildParameters, buildToolPluginInvocationResults: [BuildToolPluginInvocationResult], prebuildCommandResults: [CommandPluginResult], observabilityScope: ObservabilityScope) -> (pluginDerivedSources: Sources, pluginDerivedResources: [Resource]) func pluginsPerModule(satisfying buildEnvironment: BuildEnvironment) -> [ResolvedModule.ID : [ResolvedModule]]