Forum Xamarin.Forms

IOS app runs in simulator but failed in IPhone

Srinivas_SSrinivas_S INMember ✭✭
edited April 2017 in Xamarin.Forms

Hello all,

I have a problem with IOS app which is developed using Xamarin Forms PCL . I'm running the app in IOS 9 simulator through MAC Agent which is connected to my Visual Studio (2015) in Windows 10 machine and Xcode 8.2.1 (BC1002) is installed in my MAC. When I run the app in simulator, it works just fine. I have tried installing the same on my Iphone5s and 4s, getting an error as 'Table column not found'. It's happening while creating SQLite table on IPhone device. But, my app is working very well in Android devices.

My code for DB creation as follows:

      public static void InitializeDatabase(ISQLitePlatform sqlitePlatform)
            var dbPath = FileSystem.Current.LocalStorage.CreateFileAsync("xyz.db", CreationCollisionOption.OpenIfExists).Result;
            xyzDB = new SQLiteConnection(sqlitePlatform, dbPath.Path);

Table creation as follows:


       private static bool CreateTableWithVersion(int VersionNo)
            var retval = false;           
                if (GetTableVersionNumber(typeof(T).Name) != VersionNo)
                    UpdateTableVersionNumber(typeof(T).Name, VersionNo);
                    retval = true;
            return retval;

I'm looking for some help as I'm very new to Xamarin with IOS.
Kindly help me with this issue.

Thank you!
Srinivas. S

Best Answers


  • Srinivas_SSrinivas_S INMember ✭✭
    edited April 2017

    My table structure is like this

    public class DataModel
    public static readonly int Version =1 ;

        [PrimaryKey, Indexed]
        public long EmployeeKey { get; set; }
        public string EmployeeID { get; set; }
        public string EmployeeName { get; set; }
        public int CompanyID { get; set; }
  • Srinivas_SSrinivas_S INMember ✭✭


    But I think, we won't create separate create separate database for each plot form in Xamarin form PCL project type right?!
    we use the same database in all the plot forms like Android, Windows & IOS etc !

  • Sahadev_GuptaSahadev_Gupta INMember ✭✭✭

    @Srinu1990 Yes.. for that you need to return the database connection so that you can use the same database connection whenever you load the App

  • Srinivas_SSrinivas_S INMember ✭✭

    I'm passing the same just like below in AppDelegate

           var sqlitePlatform = new SQLitePlatformIOS();
            LoadApplication(new App(sqlitePlatform));
            return base.FinishedLaunching(app, options);

    and creating database as explained above

Sign In or Register to comment.