Use access level on import in resource_bundle_accessor.swift#1447
Closed
snprajwal wants to merge 1 commit into
Closed
Use access level on import in resource_bundle_accessor.swift#1447snprajwal wants to merge 1 commit into
snprajwal wants to merge 1 commit into
Conversation
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. This generated file imports Foundation but does not specify an access level. With Swift 6.0, access-level-on-import is part of the language mode, meaning that if a target specified a resource and contained a non-public import of Foundation, the build would fail with: ``` error: ambiguous implicit access level for import of 'Foundation' ``` This patch updates the generation logic to include an explicit `public` access level modifier for the Foundation import in `bundle_resource_accessor.swift` if the Swift version is >= 6.0.
Author
|
@swift-ci please test |
owenv
requested changes
Jun 9, 2026
owenv
left a comment
Collaborator
There was a problem hiding this comment.
Determining the access level based on the language mode alone would be a breaking change. Realistically, I think this will probably need to become configurable via the package manifest and go through the evolution process
Author
|
That makes sense, thanks. I'll pitch a better fix for this on the forums, and take it forward from there. Closing this PR for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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. This generated file imports Foundation but does not specify an access level. With Swift 6.0, access-level-on-import is part of the language mode, meaning that if a target specified a resource and contained a non-public import of Foundation, the build would fail with:
This patch updates the generation logic to include an explicit
publicaccess level modifier for the Foundation import inbundle_resource_accessor.swiftif the Swift version is >= 6.0.Fixes swiftlang/swift-package-manager#10163
Additional testing
swift-tools-version: 6.0.internal import Foundation.swift build --build-system swiftbuild.Without this patch, the build fails with the above specified error. With this patch, the build succeeds.