Question or problem
Hi @pepicrft, I opened tuist/tuist#10616 and wanted to check whether this is behavior Tuist is expected to support.
When Tuist evaluates a Package.swift, accessing PackageDescription.Context.environment crashes manifest evaluation:
let demoContextValue = Context.environment["DEMO_CONTEXT_VALUE"]
The crash is:
PackageDescription/Context.swift:19: Fatal error:
'try!' expression unexpectedly raised an error:
Could not decode ContextModel parameter.
My current understanding is that PackageDescription.Context.environment depends on ContextModel.decode(), which expects a -context argument in ProcessInfo.processInfo.arguments. SwiftPM appends that -context argument when it evaluates a manifest, but the Tuist manifest evaluation command shown in the error does not include it.
Expectation
I expected this to behave like SwiftPM’s manifest evaluation, where Context.environment can be read successfully. If Tuist intentionally does not support PackageDescription.Context APIs in package manifests, then a clearer diagnostic or documentation note would also make sense.
Context
- GitHub issue: PackageDescription.Context.environment crashes when Tuist evaluates Package.swift · Issue #10616 · tuist/tuist · GitHub
- Tuist version: 4.174.2
- macOS: 15.7.4
- Xcode: 26.3
Reproduction
The issue includes a small DemoKit sample. The minimal trigger is a top-level Package.swift access to Context.environment.
Tuist crashes:
DEMO_CONTEXT_VALUE=hello tuist generate --no-open
SwiftPM can evaluate the same manifest successfully:
DEMO_CONTEXT_VALUE=hello swift package dump-package
Could you confirm whether Tuist is expected to support this PackageDescription.Context behavior when evaluating Package.swift? If yes, I would be happy to submit a PR to fix it.