I have a Xamarin Forms application that works fine on Android, but when I run on iOS, I get this error when I set up the database
Method not found: string SQLitePCL.raw.sqlite3_column_name(SQLitePCL.sqlite3_stmt,int)
and then when I try to insert into the database table
Method not found: string SQLitePCL.raw.sqlite3_errmsg(SQLitePCL.sqlite3)
The application uses mvvmlight and I have the sqlite-net-pcl package installed there and also in the platform code. The versions all marry up.
My iOS initialising code for sqlite looks like this (on the platform)
public class SQLiteConnectionFactory : ISqliteConnectionFactory
{
readonly string Filename = "mydb";
public SQLiteConnection GetConnection()
{
var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
path = Path.Combine(path, Filename);
SimpleIoc.Default.Register<ISqliteConnectionFactory, SQLiteConnectionFactory>();
return new SQLiteConnection(path, SQLiteOpenFlags.Create | SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.SharedCache);
}
and the insert code (in the mvvmlight project) like this
public void SaveListData<T>(List<T> toStore)
{
try
{
lock (dbLock)
{
connection.InsertAll(toStore);
}
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
I've had issues with Xam.Android and sqlite-net-pcl, but never on iOS
I have the sqlite-net-pcl 1.7.302-beta and SQLitePCL.* 2.0.2 packages installed (using the beta version to prevent some of the linking issues on the stable version)
Below is a shot of the iOS packages installed
