In 2018, what is the correct way to use native dynamic libraries?

JimBordenJimBorden USMember ✭✭
edited March 2018 in Xamarin.iOS

NOTE I am referring to a C library, not an Objective-C one.

I thought I was doing things correctly by including the dylib in the app bundle and then loading it via dlopen. This worked very well in testing on both device and simulator, but then a user reported this:

ERROR ITMS-90171: “Invalid Bundle Structure - The binary file ‘myapp.app/libLiteCore.dylib’ is not permitted. Your app can’t contain standalone executables or libraries, other than a valid CFBundleExecutable of supported bundles. Refer to the Bundle Programming Guide at https://developer.apple.com/go/?id=bundle-structure1 for information on the iOS app bundle structure.”

I was following the documentation here but I wonder if this entire section is invalid? Or only works for dynamic libraries that are preinstalled on the system? Is the requirement that everything needs to be a static library still current?

Answers

  • JimBordenJimBorden USMember ✭✭

    This is a stupidly serious problem now....I have a library that I've been developing for over a year with this method on the assumption that since it is working it is ok (silly me right?? Thanks Apple...). I have vast amounts of PInvoke methods that run on multiple platforms that all do this ok using "LiteCore" as their DllImport name. However, even if I manage to dlopen the dynamic library inside of the framework I get treated to a lovely DllNotFoundException. It outright requires it to be "@rpath/LiteCore.framework/LiteCore"

    Is there any way that I can get it to load so that I can use it WITHOUT having the difference on Xamarin iOS vs everything else (.NET Core, Xamarin Android, UWP).

Sign In or Register to comment.