9.5 C
New York
Thursday, November 28, 2024

ios – Unable to Reference XCFramework Bundle


I’m at the moment growing an SDK in XCFramework format, however I’m going through points displaying photographs. The pattern repository might be discovered right here.

The Instance goal is the SDK and contains an Property.xcassets folder. Inside Property.xcassets, there’s a picture named neko.png, which I’m attempting to show in MyImage.swift.

Right here’s the related code snippet from MyImage.swift:

public var physique: some View {
    HStack {
        Picture("neko")
            .resizable()
            .body(width: 100, peak: 100)
        Picture("neko", bundle: Bundle(identifier: "com.instance.Instance"))
            .resizable()
            .body(width: 100, peak: 100)
        Picture("neko", bundle: Bundle(for: Dummy.self))
            .resizable()
            .body(width: 100, peak: 100)
    }
}

The ExampleApp goal is an iOS app that simulates the combination of the SDK. I’ve linked Instance.framework by way of “Frameworks, Libraries, and Embedded Content material.” In ContentView.swift, I name MyImage():

var physique: some View {
    VStack {
        MyImage()
        Picture(systemName: "globe")
            .imageScale(.massive)
            .foregroundStyle(.tint)
        Textual content("Good day, world!")
    }
    .padding()
}

Nonetheless, when operating ExampleApp, I encounter the next error, and the picture doesn’t show:

 No picture named 'neko' present in asset catalog for /Customers/xxxxx/Library/Developer/CoreSimulator/Units/xxxxx/information/Containers/Bundle/Software/xxxxx/ExampleApp.app

The picture just isn’t displayed

Including neko.png to ExampleApp’s Property.xcassets resolves the difficulty.

The picture is displayed

Evidently I’m not passing the bundle accurately when calling Picture() in MyImage.swift. Moreover, after I run print(Bundle.allFrameworks) inside ExampleApp, Instance.framework doesn’t seem like included.
I additionally tried including the .xcframework constructed utilizing xcodebuild to “Frameworks, Libraries, and Embedded Content material” as an alternative of Instance.framework, but it surely didn’t resolve the difficulty.

If anybody has insights on the right way to resolve this, I’d significantly respect it!

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles