Skip to content

Ambiguous implicit access level for Foundation import in resource_bundle_accessor.swift #10163

Description

@snprajwal

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

When a Swift package specifies a resource as part of a build target, SwiftPM synthesizes a resource_bundle_accessor.swift to provide runtime hooks to access the resource. With Swift 6.1, if the target uses access levels on import (internal/private/public import), then the target fails to build with:

error: ambiguous implicit access level for import of 'Foundation'

Once any other file in the same module declares an access-qualified import, the compiler requires every import in the module (including this generated one) to be explicit. As users cannot modify this file, the only workaround for this issue is to make the Foundation import in the package public.

Expected behavior

The generated resource_bundle_accessor.swift declares an access level for its imports, and allows the target to build successfully.

Actual behavior

The build fails with:

error: ambiguous implicit access level for import of 'Foundation'

Steps to reproduce

  1. Create a package with swift-tools-version: 6.1.
  2. Add a target with resources: [.copy("SomeFolder")] so SwiftPM synthesizes resource_bundle_accessor.swift.
  3. In one of that target's source files, add internal import Foundation.
  4. Run swift build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions