Describe the bug
On Linux, Bundle.urls(forResourcesWithExtension:subdirectory:) returns [NSURL]? instead of [URL]?. This causes a cascade of type errors when iterating the result, because NSURL properties (path, lastPathComponent, pathExtension) are String? rather than String, and methods like deletingPathExtension() and path(percentEncoded:) from the Swift URL type are unavailable.
The singular variant Bundle.url(forResource:withExtension:) returns URL? consistently on both platforms and is unaffected.
To Reproduce
Create a new Swift package and add to main.swift:
import Foundation
let urls = Bundle.module.urls(forResourcesWithExtension: "png", subdirectory: nil) ?? []
for url in urls {
// Linux: url is NSURL — these all fail to compile:
let key = url.deletingPathExtension().lastPathComponent
let path = url.path(percentEncoded: false)
let ext = url.pathExtension
// ^^^ compile fine on macOS
}
Expected behavior
Independent of platform, Bundle.module.urls(forResourcesWithExtension: "png", subdirectory: nil) ?? [] returns an array of URL (Array<URL>)
Configuration (please complete the following information):
- Swift Version: Swift 6.3
- OS: latest macOS, Ubuntu 24.04
Describe the bug
On Linux,
Bundle.urls(forResourcesWithExtension:subdirectory:)returns[NSURL]?instead of[URL]?. This causes a cascade of type errors when iterating the result, because NSURL properties (path, lastPathComponent, pathExtension) are String? rather than String, and methods like deletingPathExtension() and path(percentEncoded:) from the Swift URL type are unavailable.The singular variant
Bundle.url(forResource:withExtension:)returnsURL?consistently on both platforms and is unaffected.To Reproduce
Create a new Swift package and add to
main.swift:Expected behavior
Independent of platform,
Bundle.module.urls(forResourcesWithExtension: "png", subdirectory: nil) ?? []returns an array of URL (Array<URL>)Configuration (please complete the following information):