Skip to content

[SwiftPM] Support conditional compilation in plugins #161182

@loic-sharma

Description

@loic-sharma

Background

CocoaPod plugins can use conditional compilation to allow an app to opt-in or out of certain features.

For example, the just_audio plugin is an audio player that has an optional microphone feature. Since microphone use has privacy concerns, the app must provide a usage description. If the app doesn't need this microphone feature, just_audio provides a compilation flag to remove the microphone feature entirely. The app can set this compilation flag in its CocoaPods configuration. See: ryanheise/just_audio#1368 (comment)

Unfortunately, Swift Package Manager does not support conditional compilation.

Known affected packages:

  1. just_audio
  2. permission_handler

Work

Options:

  1. Document the known workaround. The workaround is hacky and not ideal...
  2. Update Flutter to support Swift package traits if/when that lands

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityplatform-iosiOS applications specificallyplatform-macBuilding on or for macOS specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions