Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvvmcross sqlite-net plugin for monotouch

I am implementing the excellent mvvmcross library in a multiplatform enterprise application. The monodroid sqlite plugin is working - I now need to implement monotouch functionality though. I was interested if anyone had developed an accompanying sqlite plugin for the ios/monotouch platform and describing the complexity involved and path taken, stumbling blocks etc. Cheers

like image 731
Kern Avatar asked Sep 10 '26 22:09

Kern


2 Answers

This should be quite straight-forward to...

  1. Using MonoDevelop on the Mac, create a new MonoTouch library project - Cirrious.MvvmCross.Plugins.Sqlite.Touchin the folder /MvvmCross/Cirrious/Plugins/Sqlite/
  2. Set the build paths for debug and release to ../../../../bin/Touch/debug and ../../../../bin/Touch/release
  3. Add references to: Cirrious.MvvmCross (core PCL), Cirrious.MvvmCross.Touch (core MonoTouch methods), Cirrious.MvvmCross.Plugins.Sqlite (core SQLite functions)
  4. Add the 'boilerplate' plugin file - which just registers the connection factory in DI - see below
  5. Add the connection factory class - see below
  6. Add a link to the sqlite-net file in the Droid plugin - SQLiteNet.cs
  7. Build
  8. When you use this plugin in a MonoTouch UI project, you will need to register the plugin instance in your setup.cs file - just as you do all Touch plugins - this is because we can't use Assembly.Load() at runtime
  9. You may also need to do something special to use the plugin at runtime too - not sure - not used SQLite-net in MonoTouch yet - the Sqlite samples should help - https://github.com/praeclarum/sqlite-net/tree/master/examples/StocksTouch

My attempt at this is: https://github.com/slodge/MvvmCross/tree/vnext/Cirrious/Plugins/Sqlite/Cirrious.MvvmCross.Plugins.Sqlite.Touch

But I've not tested this.

Would love to read about it if it works... and to see a pull to fix it if it doesn't.

like image 97
Stuart Avatar answered Sep 13 '26 06:09

Stuart


Have you seen this blog post? http://slodge.blogspot.nl/2012/10/a-sqlite-example-vnext-portable.html

"Note that I've only done the Droid implementation of this plugin so far, but I think all of the rest - WP7, MonoTouch, and WinRT (and beyond) should be straight-forward - and that the same SQLiteNet.cs file (#if's and all) will be link-shared between those plugins."

Have you tried using the same SQLite plugin for the monotouch project?

like image 34
Jvdbrink Avatar answered Sep 13 '26 05:09

Jvdbrink



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!