Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image used inside iOS framework is not loading on Test App

Goal - Create a framework "F" with UI Component and Image assets inside framework. I am using SwiftUI Framework returns a UI component with some images to user of this framework. User doesn't need to know anything what image he is going to get from framework.

Expectation - When User integrate this framework using Carthage and call UI api from framework he should get a UI view with some text and image.

Actual - User is getting the text but Images are not coming up.

Error - TestApp[87355:3127354] [SwiftUI] No image named 'Apple' found in asset catalog for /Users/AT09/Library/Developer/CoreSimulator/Devices/C6BCA75A-DE25-4F7D-992F-AED8412B483C/data/Containers/Bundle/Application/B7E13C38-0ED0-4565-AC4B-3527582DEB09/TestApp.app

I tried creating bundle as suggested in this thread, but it doesn't work.

Code to load Image in Framework, "Apple" is Image in .xcassests in framework

Image("Apple") .renderingMode(.original) .resizable() .scaledToFit() .padding(.vertical, 20).padding(.horizontal, 20) .frame(width: 80, height: 80, alignment: .center)

UPDTAE :

If I add TestApp in target membership of Assets.xcassets, Image is loading. (TestApp is in Framework project so it was feasible) But once this Framework is shipped to client they won't be able to access xcassets. client will just get .framework

like image 628
AkashTripathi Avatar asked May 20 '26 19:05

AkashTripathi


1 Answers

Are you sure that you added the Image in xcassets? Make sure that the name is right.

Update: Perhaps this: Images inaccessible from asset catalog in a SwiftUI framework

like image 112
sheldor Avatar answered May 22 '26 11:05

sheldor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!