Skip to content

Unable to determine Swift version for audioplayers_darwin in default Objective-C Flutter module #1935

@hootigger

Description

@hootigger

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

When using a Flutter project created as a module (with the default Objective-C template) and upgrading the audioplayers package to version ^6.5.0, the pod install command, which is automatically triggered by flutter run, fails.
The error message is:

[!] Unable to determine Swift version for the following pods:

- `audioplayers_darwin` does not specify a Swift version and none of the targets (`Runner`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

Analysis of the Root Cause
The core issue seems to be a combination of two factors:
By default, flutter create -t module my_module generates an Objective-C based .ios project. Consequently, the Runner target in Xcode does not have the SWIFT_VERSION build setting defined.
The audioplayers_darwin pod requires Swift to compile but does not specify a default Swift version in its own podspec. CocoaPods then tries to inherit this setting from the integrating target (Runner), which is not available, causing the build to fail.
Temporary Workaround and Its Limitation
A temporary workaround is to manually "introduce" Swift to the generated .ios project:
Open .ios/Runner.xcworkspace.
Add a new, empty Swift file to the Runner group.
When prompted, create the Objective-C Bridging Header.
This makes the SWIFT_VERSION build setting appear in the Runner target's Build Settings, which can then be set to 5.0.
While this works, it is not a practical solution for module-based workflows. The .ios directory is considered ephemeral and is often regenerated, especially in CI/CD pipelines or when building the final framework for integration into a native host app. Having to perform this manual step each time is tedious and error-prone.

Expected behaviour

can works for flutter module(flutter run mode)

Steps to reproduce

  1. Execute flutter run on the code sample
  2. ...
  3. ...

Code sample

Code sample
void main() {
}

Affected platforms

iOS

Platform details

No response

AudioPlayers Version

6.5.0

Build mode

release

Audio Files/URLs/Sources

No response

Screenshots

No response

Logs

my relevant logs
Full Logs
my full logs or a link to a gist

Flutter doctor:

Output of: flutter doctor -v

Related issues / more information

No response

Working on PR

no way

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions