googlesamples / googlesamples/unity-jar-resolver

[Bug] [SPM] Dynamic frameworks and resource bundles are never copied into the .app

Open
#779 6 comments 0 reactions 0 assignees View on GitHub
Swift Package Manager type: bug
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.3.19f1
* External Dependency Manager version: 1.2.188
* Source you installed EDM4U: Unity Package Manager
* Features in External Dependency Manager in use: iOS Resolver
* Plugins SDK in use: AppLovinSDK (can be reproduced with any other dynamic framework)
* Platform you are using the Unity editor on: Mac

### [REQUIRED] Please describe the issue here:
(Please list the full steps to reproduce the issue. Include device logs, Unity logs, and stack traces if available.)

Since 1.2.187 the iOS Resolver can add Swift Packages to the generated Xcode project. It links their products against the `UnityFramework` target and stops there.

Xcode embeds a package's artifacts implicitly only when the product is linked against an **application** target. Because the products are linked against a framework target instead, two kinds of artifacts never reach the built `.app`:

1. Dynamic frameworks - the app fails to launch with `dyld: Library not loaded: @rpath/...`
2. SPM resource bundles - `Bundle.module` aborts with `Fatal error: unable to find bundle named ...` (already filed as #766)

The CocoaPods path was never affected, because CocoaPods generates two shell script build phases on the **application** target - `[CP] Embed Pods Frameworks` and `[CP] Copy Pods Resources`. The Swift Package path has no equivalent for either.

```
Error loading /var/containers/Bundle/Application/44B3D6A3-D36D-417F-AA53-3CC738028390/SPMDynamicFrameworkReproProj.app/Frameworks/UnityFramework.framework/UnityFramework (155): dlopen(/var/containers/Bundle/Application/44B3D6A3-D36D-417F-AA53-3CC738028390/SPMDynamicFrameworkReproProj.app/Frameworks/UnityFramework.framework/UnityFramework, 0x0109): Library not loaded: @rpath/AppLovinSDK.framework/AppLovinSDK
Referenced from: /private/var/containers/Bundle/Application/44B3D6A3-D36D-417F-AA53-3CC738028390/SPMDynamicFrameworkReproProj.app/Frameworks/UnityFramework.framework/UnityFramework
Reason: tried: '/usr/lib/swift/AppLovinSDK.framework/AppLovinSDK' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/44B3D6A3-D36D-417F-AA53-3CC738028390/SPMDynamicFrameworkReproProj.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/44B3D6A3-D36D-417F-AA53-3CC738028390/SPMDynamicFrameworkReproProj.app/Frameworks/UnityFramework.framework/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/usr/lib/swift/AppLovinSDK.framework/AppLovinSDK' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/44B3D6A3-D36D-417F-AA53-3CC738028390/SPMDynamicFrameworkReproProj.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/44B3D6A3-D36D-417F-AA53-3CC738028390/SPMDynamicFrameworkReproProj.app/Frameworks/UnityFramework.framework/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file), '/private/var/containers/Bundle/Application/44B3D6A3-D36D-417F-AA53-3CC738028390/SPMDynamicFrameworkReproProj.app/Frameworks/AppLovinSDK.framework/AppLovinSDK' (no such file)
```

#### Please answer the following, if applicable:
What's the issue repro rate? (eg 100%, 1/5 etc)
**100%**

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

1. Create an empty Unity project and switch the platform to iOS.
2. Import EDM4U 1.2.188.
3. Add `Assets/Editor/SpmTestDependencies.xml`:
```



```
4. Leave Swift Package Manager Enabled at its default (on).
5. Build for iOS and run on a physical device.

If you have a downloadable sample project that reproduces the bug you're reporting, you will
likely receive a faster response on your issue.

https://github.com/dmitriifeshchenko/SPMDynamicFrameworkReproProj

Contributor guide

Open the contributing guide

Research direction

Start with the iOS Resolver's Swift Package integration and the generated Xcode project. Reproduce the issue using Assets/Editor/SpmTestDependencies.xml and inspect the application target after an iOS build. Done means the built .app contains dynamic frameworks and Swift Package resource bundles so the repro launches successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, ios, swift, unity
Domain
build-system, mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.