简体   繁体   中英

SQLite-net PCL and Xamarin.Forms

I have a problem with this Nuget Package: https://www.nuget.org/packages/sqlite-net-pcl/1.0.11

In my test Case I have a PCLLibrary called "PCL" with this NuGet Package. And an emtpy class which has

using SQLite;
namespace PCL
{
    public class Test
    {

    }
}

Now I create a new Xamarin.Forms PCL Project and reference this Library

using System;
using Xamarin.Forms;

namespace PCL
{
    public class App : Application
    {
        public App ()
        {
            // The root page of your application
            MainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        new Label {
                            XAlign = TextAlignment.Center,
                            Text = "Welcome to Xamarin Forms!"
                        }
                    } 
                }
            };
            var test = new Test();
        }
    }
}

Now I run my App in iOS Simulator and it gets killed ... When i am not creating an instance of Test this App starts fine... When I integrate this Package directly in my Forms Library, I can use it normally. What can cause this?

Normally when you are dealing with NuGet packages on PCL's you need to add the NuGet package on the iOS project as well as the PCL. This is because it may have some platform specific code in it (will definitely be the case with a SQLite library).

When you add it to the iOS project it loads the specific assemblies for iOS that is needed. Its just something you need to be aware of.

Also I would recommend this package: https://www.nuget.org/packages/SQLite.Net-PCL/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM