Skip to content

Replace the OTEL_SWIFT env var with a Package.Dependency.Trait? #2339

@mpederson-mlb

Description

@mpederson-mlb

Question

We are using OpenTelemetry alongside Datadog, and we are going to have to find a viable workaround for Datadog iOS SDK's requirement that the OTEL_SWIFT environment variable is defined at package resolution time.

I ask this question in the context of #2252, where I commented last week:

Would a Trait be a viable replacement for the environment variable?

From SE-0450: Package traits

Motivation - Replacing environment variables in Package manifests
A lot of packages are using environment variables in their Package.swift to configure their package. This has various reasons such as optional dependencies or setting certain defines for local development. Using environment variables inside Package.swift is not officially supported and with stricter sandboxing rules might break in the future.

Of course I'm not surprised that my comment on a closed ticket has not seen a response, and I am opening a new issue with hopes of getting this idea some attention and consideration. I would be perfectly happy to see this issue closed in favor of reopening #2252, or happy for that issue's discussion to pick back up in this issue.

An approach leveraging a Trait may have some challenges, but it seems quite promising as it appears to be intended for purposes and situations just like this one. For example of a challenge, Trait requires Xcode 16.3, so the SDK might need to support more than one approach for some time.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions