xamarinxamarin.iosxamarin-studioxamarin-linker

Linking libz.dylib and libsqlite3.dylib in Xamarin iOS Project


I created a Xamarin iOS binding project that requires the following frameworks:

SystemConfiguration.framework
CoreTelephony.framework
libz.dylib
libsqlite3.dylib

I added the following line in my iOS binding project to the linkwith.cs file:

Frameworks = "SystemConfiguration CoreTelephony"

This seems to work correctly and tells that project to include these frameworks when binding. From what I have read, it sounds like the remaining 2 libraries need to be added as linker flags in the project referring to the DLL generated from my iOS binding project. So I created a test app, imported the DLL, and now need to add the linker flags but my project cannot find the right libraries.

My linker flags in Xamarin Studio are as follows:

-gcc_flags "-lz -lsqlite3.0"

When I build my Xamarin test app I get a few errors regarding the frameworks that cannot be found. Are there additional flags that need to be linked or do I need to do some additional configuration in my iOS binding project?


Solution

  • I found a great resource: http://ipixels.net/blog/specify-extra-gcc-flags-for-native-library-binding-in-xamarin-ios/

    I needed to add LinkerFlags = "-lz -lsqlite3.0" to my .linkwith.cs file. I then rebuilt the library to generate a new DLL and added this to my test app. The test app builds correctly then.