Skip to content

Resources

Bundle is supported on Android. SPM package resources declared in Package.swift are accessible at runtime via the standard Bundle API.

See Resources for how resources are packaged into archives and how the SCADE Android Swift SDK handles bundle access automatically.

Resources must be declared in the target’s resources array in Package.swift:

.target(
name: "MyLibrary",
resources: [
.process("Resources"), // process and optimize (e.g. asset catalogs)
.copy("Data/config.json") // copy as-is, preserving path
]
)

Use .process() for files that the build system should optimize (images, asset catalogs), and .copy() for files that should be included as-is.

Use Bundle.module to access resources from within the package that declares them:

// Access a file resource
if let url = Bundle.module.url(forResource: "config", withExtension: "json") {
let data = try Data(contentsOf: url)
}

Load a string resource:

if let path = Bundle.module.path(forResource: "template", ofType: "txt") {
let content = try String(contentsOfFile: path)
}