You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `url(forResource:withExtension:subdirectory:localization: )` resource location method is (at best) inconsistent across platforms and can (at worst) cause a "core dumped" error when used with a Swift Package which includes resources.
The attached `CLIQuickstartLib` project is a standalone, very-close-to-minimal Swift Package which is set up to evaluate access approaches to package resources. Resources are included for each of the targets: library, executable and tests.
The resource access evaluation scenarios factors include:
platform: Linux, macOS
build chain execution: Linux command line interface (CLI), macOS command line interface (CLI), macOS Xcode IDE (open from Package.swift directly, not an `generate-xcodeproj`)
top level resources directory name: `Resources` or something else
resource asset directory level: top level or some sub directory
use of localization
In particular, the `checkResourceAccessApproaches()` method in `SpmHelper.swift` partially enumerates various ways that `url(forResource:withExtension:…)` might be called to access package resources.
In general, `url(forResource: …)` is expected to reliably handle cross-platform differences in a reliably consistent and robust way. However, it does not.
Top level resource assets can not accessed in a uniform, reliable way across platforms. (i.e. without using #if os(…))
Top level resource directory name affects how assets can be successfully accessed.
In some cases, Swift Foundation on Linux exhibits a fatal "core dumped" runtime error. (this really should fail more gracefully!)
Localized files cannot be access in the same way on the Linux and macOS command build/test/run.
Localized files cannot be access via the localization argument if `Package.swift` is opened with Xcode.
Replication Steps
Run the `CLIQuickstartLib` package on the macOS and Linux terminal command line.
swift build
swift run
swift test
For Xcode, open Package.swift directly. Do not use `generate-xcodeproj`. Set the schema to "CLIQuickstartTool > My Mac". Use the Xcode menus "Product > Build", "Product > Run", and "Product > Test"
Look at the console results in all cases.
The text was updated successfully, but these errors were encountered:
Attachment: Download
Environment
macOS CLI (command line)
Swift Package Manager - Swift 5.5.0
swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Target: x86_64-apple-macosx11.0
macOS: macOS 11.6.2 (20G314)
macOS Xcode
Linux CLI (command line)
Swift Package Manager - Swift 5.5.0
Swift version 5.5.2 (swift-5.5.2-RELEASE)
Target: x86_64-unknown-linux-gnu
Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-92-generic x86_64)
Additional Detail from JIRA
md5: 5b8896cfd86d3915bdc8affb3b131069
Issue Description:
The `url(forResource:withExtension:subdirectory:localization: )` resource location method is (at best) inconsistent across platforms and can (at worst) cause a "core dumped" error when used with a Swift Package which includes resources.
The attached `CLIQuickstartLib` project is a standalone, very-close-to-minimal Swift Package which is set up to evaluate access approaches to package resources. Resources are included for each of the targets: library, executable and tests.
The resource access evaluation scenarios factors include:
platform: Linux, macOS
build chain execution: Linux command line interface (CLI), macOS command line interface (CLI), macOS Xcode IDE (open from Package.swift directly, not an `generate-xcodeproj`)
top level resources directory name: `Resources` or something else
resource asset directory level: top level or some sub directory
use of localization
In particular, the `checkResourceAccessApproaches()` method in `SpmHelper.swift` partially enumerates various ways that `url(forResource:withExtension:…)` might be called to access package resources.
In general, `url(forResource: …)` is expected to reliably handle cross-platform differences in a reliably consistent and robust way. However, it does not.
However, here is a table of what was observed:
⚑ Fatal Runtime Error (Linux CLI)
Issues
Top level resource assets can not accessed in a uniform, reliable way across platforms. (i.e. without using #if os(…))
Top level resource directory name affects how assets can be successfully accessed.
In some cases, Swift Foundation on Linux exhibits a fatal "core dumped" runtime error. (this really should fail more gracefully!)
Localized files cannot be access in the same way on the Linux and macOS command build/test/run.
Localized files cannot be access via the localization argument if `Package.swift` is opened with Xcode.
Replication Steps
Run the `CLIQuickstartLib` package on the macOS and Linux terminal command line.
swift build swift run swift test
For Xcode, open Package.swift directly. Do not use `generate-xcodeproj`. Set the schema to "CLIQuickstartTool > My Mac". Use the Xcode menus "Product > Build", "Product > Run", and "Product > Test"
Look at the console results in all cases.
The text was updated successfully, but these errors were encountered: