I've searched for similar issues and found this post and other similar reports, however these all seem to be using static libraries. I tried switching BaseLibrary to be a static library and everything works as expected, so it seems the issue only arises when using a dynamic library.
Expected behavior
The test target ClientLibraryTests passes
Actual behavior
ClientLibraryTests crashes with the following error:
BaseLibrary/resource_bundle_accessor.swift:40: Fatal error: unable to find bundle named BaseLibrary_ BaseLibrary
Double click on ClientLibrary/Package.swift to open the project with Xcode
Select Product > Test (cmd-U)
Swift Package Manager version/commit hash
5.7
Swift & OS version (output of swift --version && uname -a)
swift-driver version: 1.62.15 Apple Swift version 5.7.1 (swiftlang-5.7.1.135.3 clang-1400.0.29.51)
Target: arm64-apple-macosx12.0
Darwin M9XDHW1R40 21.6.0 Darwin Kernel Version 21.6.0: Thu Sep 29 20:13:56 PDT 2022; root:xnu-8020.240.7~1/RELEASE_ARM64_T6000 arm64
I'm seeing a similar error in generated resource_bundle_accessor.swift file which throws following error. My swift package builds fine on Xcode 13 but fails on Xcode 14.x (both 14.1 & 14.2)
Description
The generated resource bundle accessor
Bundle.module
crashes in a test target because it cannot find the bundle of a dynamically linked library.The setup is the following:
BaseLibrary
package defines a dynamic library that contains a resource fileClientLibrary
package defines another library that depends onBaseLibrary
ClientLibrary
has a test that tries to access the resource inBaseLibrary
The sample code can be found here: https://github.com/erudel/spm-dynamic-bundles/
I've searched for similar issues and found this post and other similar reports, however these all seem to be using static libraries. I tried switching
BaseLibrary
to be a static library and everything works as expected, so it seems the issue only arises when using a dynamic library.Expected behavior
The test target
ClientLibraryTests
passesActual behavior
ClientLibraryTests
crashes with the following error:Steps to reproduce
ClientLibrary/Package.swift
to open the project with XcodeProduct
>Test
(cmd-U)Swift Package Manager version/commit hash
5.7
Swift & OS version (output of
swift --version && uname -a
)EDIT: after finding https://github.com/apple/swift-package-manager/pull/3824 it seems that, if this is indeed a bug, the problem lies in the accessor generated by Xcode and not by SPM. Is anyone able to confirm this?