Looks like this has been solved by Xcode 16 (Beta 1).
Post
Replies
Boosts
Views
Activity
This is always happening in merged modules that contain a subclass of any generic UIViewController subclass, btw.
And it's still happening with Xcode 15.4 beta 1.
Sorry, I must have confused something in my testing. This actually only works with Release configuration on device, not in Debug configuration. (on simulator it always works)
I have looked into the generated app bundle for different builds and compared the value returned by Bundle(for: SomeClass.self) where SomeClass is part of the merged framework:
Simulator/Debug
Bundle Path: /DerivedData/.../Build/Products/Debug-iphonesimulator/FrameworkWithResources.framework/
✅ Resources can be found
Device/Debug
Bundle Path: /var/containers/Bundle/Application/.../MergeableResources.app/ReexportedBinaries/FrameworkWithResources.framework/
Actual Contents of App Bundle:
Frameworks/FrameworkWithResources.framework/
FrameworkWithResources (stub, 35kB)
Assets.car
...
ReexportedBinaries/FrameworkWithResources.framework/
FrameworkWithResources (real, 104kB)
No Resources
...
❌ Resources can not be found because Bundle URL does not match contents of app bundle
Device/Release
Bundle Path: /var/containers/Bundle/Application/.../MergeableResources.app/Frameworks/FrameworkWithResources.framework/
Actual Contents of App Bundle:
Frameworks/FrameworkWithResources.framework/
FrameworkWithResources (stub, 35kB)
Assets.car
...
No ReexportedBinaries folder (as expected)
✅ Resources can be found
Oh and another point of confusion is that everything works great when not embedding the merged framework, even on device, as long as it does not contain any resources.
When you use a mergeable framework in your app, you still need to embed the framework so that you get all of its resources. However, what gets embedded is a cut down framework, with all the resources but only a stub Mach-O image.
Interesting! That explains a lot and was not clear to me at all. (Also it does not seem to be documented anywhere?)
In the beginning I analyzed the app bundle to find out if this feature really works as expected and just assumed that something was wrong because I expected that:
The resources are part of the framework in "ReexportedBinaries" folder in debug builds (which they are not)
The whole merged ".framework" folder should not exist at all in release builds (which it does)
Then I thought maybe I should stop embedding merged frameworks and tried that.
And everything worked great - in Simulator.
And then I tried on device - and it crashed I was totally confused.
And there's also this issue, which made me think this whole feature is just horribly broken.
But apparently it's just very complex and under-documented.
Do you happen to know how to find out if a framework is just a "cut down framework" that really is merged into the app binary or not (to make really sure everything is configured correctly)?