iOSdeveloper
iOSdeveloper

Reputation: 113

Resources for an external bundle not recognized in Xamarin.iOS project

I'm using an iOS framework that comes together with an external resource bundle (the framework use some resources that are located in different folders inside of the bundle). Everything works fine if both the framework and the bundle are integrated in a Xcode project (I usually put the bundle in the Resources folder).

Here you can see the bundle path during runtime (in Xcode): @"/var/containers/Bundle/Application/44691B5C-73D0-4B28-B88F-14ECB52AFC5F/DemoProject.app/FRAMEWORK_BUNDLE.bundle"

On the other hand, I've tried to integrate the same framework in a Xamarin iOS project. First of all, I have created an iOS binding project and added the Objective-C framework as a Native Reference. The external bundle has been added to the iOS binding project under the Resources folder. The ApiDefinition.cs and Structs.cs files have been also successfully configured. I've compiled the project and I've got the .dll file.

I have integrated the .dll file into my Xamarin iOS project under the References folder. When I try to run the project it fails because the resources from the external bundle are not visible (the framework is configured to throw an exception if it doesn't find the external resources).

Am I missing something ? Should I add the external bundle in the Xamarin iOS project and link it with the project ?

Thank you !

Upvotes: 2

Views: 1728

Answers (1)

Kevin Li
Kevin Li

Reputation: 2258

Make sure the files are marked as BuildAction = BundleResource. As the documentation Resources in Binding Projects said:

Files marked as BundleResource in a Binding Project will be embedded into the binding assembly and extracted to the correct location when referenced by a Xamarin.iOS application project.

According to How to write bindings for a framework?:

You can add these files to either the binding project or the app project, it doesn't really matter.

adding the Bundle file to the Resource folder of your Xamarin iOS project is another choice. You can have a try.

Some other references:

How to add a external Resource Bundle into the app

Embedding ObjectivC BindingLibrary with Bundle Resources

Upvotes: 1

Related Questions