googlesamples / googlesamples/unity-jar-resolver
[Bug] [SPM] resource_bundle_accessor.swift:44: Fatal error: unable to find bundle named
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 371
- Avg merge
- 14h 21m
- Merged PRs (30d)
- 3
Description
### [REQUIRED] Please fill in the following fields:
* Unity editor version: 6000.2.8f1
* External Dependency Manager version: 1.2.187
* Source you installed EDM4U: UPM
* Features in External Dependency Manager in use: Android Resolver, iOS Resolver
* Plugins SDK in use: [BitLabs SDK ](https://github.com/BitBurst-GmbH/bitlabs-ios-sdk)
* Platform you are using the Unity editor on: macOS
### [REQUIRED] Please describe the issue here:
SPM resource bundles from transitive package targets are not embedded into `UnityFramework.framework` in the Unity-generated Xcode project. This causes a runtime crash when the SDK tries to load resources.
**Repro rate**: 100%
A Swift package (`bitlabs-ios-sdk`) declares three targets:
```swift
.target(name: "BitLabsShared", path: "BitLabs/Shared"), // contains xib, xcassets, .strings
.target(name: "BitLabs", dependencies: ["BitLabsShared"], path: "BitLabs/Core"),
.target(name: "BitLabsUnity", dependencies: ["BitLabsShared"], path: "BitLabs/Unity"),
```
The `BitLabsShared` target contains resources (a `.xib`, `.xcassets`, and `.lproj` localization folders). SPM auto-generates a `BitLabs_BitLabsShared.bundle` containing them, and a `Bundle.module` accessor that looks for this bundle at runtime.
The Unity UPM package declares its iOS dependency via EDM4U:
```xml
```
**Expected behavior:**
When `BitLabsUnity` is linked into `UnityFramework` and `BitLabsUnity` depends on `BitLabsShared` (which has resources), `BitLabs_BitLabsShared.bundle` should be embedded into `UnityFramework.framework` (or the app bundle) so `Bundle.module` can find it at runtime.
**Actual behavior:**
After Unity export and Xcode build:
- `BitLabs_BitLabsShared.bundle` is built and exists at `/Build/Products//BitLabs_BitLabsShared.bundle`
- The bundle is **not** inside `.app`
- The bundle is **not** inside `.app/Frameworks/UnityFramework.framework`
At runtime, `Bundle.module` calls `fatalError` because none of its lookup candidates contain the bundle:
```
BitLabsShared/resource_bundle_accessor.swift:44: Fatal error: unable to find bundle named BitLabs_BitLabsShared
```
**Reproduction:**
1. Clone this branch that reproduces the bug: https://github.com/BitBurst-GmbH/bitlabs-unity/tree/ios-spm-migration.
2. Export the iOS project from Unity.
3. Build and run on simulator or device.
4. Trigger code that calls `Bundle.module` (**Show Surveys** button) from the transitive target.
5. Observe the crash.
Contributor guide
Assessment
This issue has not been assessed yet.