ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

MacCatalyst support #471

Closed ericsink closed 2 years ago

ericsink commented 2 years ago

the app works on iOS but crashes on maccatalyst

Originally posted by @VladislavAntonyuk in https://github.com/ericsink/SQLitePCL.raw/issues/468#issuecomment-1032136588

coolbluewater commented 2 years ago

@ericsink I get the same exception with the sample you attached.

ericsink commented 2 years ago

@coolbluewater One difference is you said you're using the IDE and I'm using the command line. Does it work for you from the command line? (cd into that directory and type dotnet run)

coolbluewater commented 2 years ago

@ericsink - yes, that worked. (A red screen appears with "Hello, Catalyst 3.37.0".)

coolbluewater commented 2 years ago

@ericsink Are you able to reproduce the crash via the IDE?

ericsink commented 2 years ago

Okay, so that's progress.

I don't have the latest VS for Mac installed right now, but as soon as I can, I will install it and try to reproduce what you are seeing.

coolbluewater commented 2 years ago

Awesome-o. Thanks.

coolbluewater commented 2 years ago

@ericsink Incidentally, your project uses a TFM of .net6.0-maccatalyst15.2. I don't believe there is such a TFM - it should just be .net6.0-maccatalyst. The official list is at https://docs.microsoft.com/en-us/dotnet/standard/frameworks.

edoust commented 2 years ago

@ericsink Just wanted to let you know the latest update is working for me on net6.0-maccatalyst15.4, did not test other versions. I am building using the latest VS for mac

ericsink commented 2 years ago

@coolbluewater In the page you linked, check out the section on "OS Version in TFMs":

https://docs.microsoft.com/en-us/dotnet/standard/frameworks#os-version-in-tfms

coolbluewater commented 2 years ago

@ericsink - Ah, I see. Thanks! BTW - my earlier tests were with the version number included so no pilot error there.

coolbluewater commented 2 years ago

@edoust - Did you mean 15.2? When I tried 15.4 in VSMac, it says that 15.4 is not a valid TargetPlatformVersion, and then lists a set of valid versions, ending in 15.2

edoust commented 2 years ago

You need to install the workload from the preview feed

coolbluewater commented 2 years ago

@edoust - Ok, will do. Also, what version of Xcode do you have?

edoust commented 2 years ago

I got 13.3.1 and I am compiling with RID maccatalyst-arm64, I did not test with maccatalyst-x64

coolbluewater commented 2 years ago

Thanks. I had installed Xcode 13.3.0 and had to downgrade to 13.2.1 because of a bug in Xcode. Will try to update to Xcode 13.3.1. I am running on x64, so fingers crossed.

coolbluewater commented 2 years ago

@edoust, what command line did you use to install the maui preview workload? I used this one from the dotnet/maui wiki:

sudo dotnet workload install maui --from-rollback-file https://aka.ms/dotnet/maui/rc.2.json --source https://aka.ms/dotnet6/nuget/index.json --source https://api.nuget.org/v3/index.json

However this gives an error that the android sdk manifest is not found:

Workload installation failed: Failed to install manifest microsoft.net.sdk.android version 32.0.300-rc.2.27: microsoft.net.sdk.android.manifest-6.0.200::32.0.300-rc.2.27 is not found in NuGet feeds https://aka.ms/dotnet6/nuget/index.json;https://api.nuget.org/v3/index.json"..

I couldn't find an open issue regarding this, and wondered if you ran into something similar.

edoust commented 2 years ago

I use sudo dotnet install workload maccatalyst since I only compile for Catalyst using the Uno framework...

I use this custom nuget.config (rename to nuget.config) and then execute the command in the context of that nuget config file

coolbluewater commented 2 years ago

@edoust Thanks - what is the source of that nuget config? Perhaps I'll find more info there about installing the maui preview...

edoust commented 2 years ago

The nuget file is not MAUI related it just contains the global feeds for dotnet and xamarin... Looks like if you specify the rc.2 json you also need more feeds, see here...

Also it seems like an rc.4 rollback file is available here

VladislavAntonyuk commented 2 years ago

use this guide to install it https://github.com/dotnet/maui/wiki/macOS-Install

coolbluewater commented 2 years ago

@edoust @VladislavAntonyuk Thanks guys, but I'm having no luck with installing either rc2 or rc4. Have you actually succeeded installing either maui rc2 or rc4? Specifically, the install halts at the first item (the android sdk) and says that it cannot find the mentioned version.

I've tried this to install rc2 using the instructions at https://github.com/dotnet/maui/wiki/macOS-Install:

dotnet workload install maui --from-rollback-file https://aka.ms/dotnet/maui/6.0.300/rc.2.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-a21b9a2d/nuget/v3/index.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-572aeedc/nuget/v3/index.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json --source https://api.nuget.org/v3/index.json

And then I tried replacing the rollback file with the url given by @edoust for rc4:

sudo dotnet workload install maui --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/rc.4.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-a21b9a2d/nuget/v3/index.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-572aeedc/nuget/v3/index.json --source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json --source https://api.nuget.org/v3/index.json

But neither work - it looks like the rollback file and the feeds must be mutually compatible, i.e. the feeds need to have items with the versions mentioned in the rollback file. Any ideas?

VladislavAntonyuk commented 2 years ago

I use rc2, because it is the latest released version. I know about upcoming rc3 very soon.

try to uninstall all workloads and install MAUI again

coolbluewater commented 2 years ago

@VladislavAntonyuk - could you please list the command line for installing maui rc2?

edoust commented 2 years ago

@coolbluewater I just tested and using this nuget config it works

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
    <add key="xamarin" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json" />
    <add key="public"  value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
    <add key="xx" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-a21b9a2d/nuget/v3/index.json"/>
    <add key="xy" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-572aeedc/nuget/v3/index.json" />
    <add key="xz" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
  </packageSources>
</configuration>

Then in the same directory of the nuget config execute the command sudo dotnet workload install maui --from-rollback-file https://maui.blob.core.windows.net/metadata/rollbacks/rc.4.json or whichever rollback file you choose

coolbluewater commented 2 years ago

@VladislavAntonyuk - that goes in a file named nuget.config, correct? I ran the command you listed and unfortunately get the same error as I previously got:

Skip NuGet package signing validation. NuGet signing validation is not available on Linux or macOS https://aka.ms/workloadskippackagevalidation .
Updated advertising manifest microsoft.net.sdk.android.
Updated advertising manifest microsoft.net.sdk.tvos.
Updated advertising manifest microsoft.net.sdk.maui.
Updated advertising manifest microsoft.net.sdk.ios.
Updated advertising manifest microsoft.net.sdk.maccatalyst.
Updated advertising manifest microsoft.net.workload.mono.toolchain.
Updated advertising manifest microsoft.net.sdk.macos.
Updated advertising manifest microsoft.net.workload.emscripten.
Installing workload manifest microsoft.net.sdk.android version 32.0.300-rc.3.45…
Workload installation failed. Rolling back installed packs...
Installing workload manifest microsoft.net.sdk.android version 31.0.200-preview.14.106…
Installation rollback failed: Failed to install manifest microsoft.net.sdk.android version 31.0.200-preview.14.106: The transaction has aborted..
Workload installation failed: Failed to install manifest microsoft.net.sdk.android version 32.0.300-rc.3.45: microsoft.net.sdk.android.manifest-6.0.200::32.0.300-rc.3.45 is not found in NuGet feeds https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json;https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-runtime-a21b9a2d/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/darc-pub-dotnet-emsdk-572aeedc/nuget/v3/index.json;https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json"..
edoust commented 2 years ago

Do you have dotnet 6.0.300 installed? can you check by running dotnet --info?

VladislavAntonyuk commented 2 years ago

You can take a look how we install dotnet and Maui workload https://github.com/CommunityToolkit/Maui/blob/main/azure-pipelines.yml

coolbluewater commented 2 years ago

@VladislavAntonyuk @edoust - thanks! I had moved back and forth between runtimes and was on a different version. After installing 6.0.300 I was able to install maui rc4 using the above steps.

coolbluewater commented 2 years ago

@ericsink I built my app for maccatalyst15.4 (I think!), but still no sqlite love. Are you able to reproduce the failure?

ericsink commented 2 years ago

@coolbluewater Are you talking about above, where it works on the command line but not in the IDE? If so, no, I haven't found time to install VS for Mac and try it yet.

VladislavAntonyuk commented 2 years ago

I can just add that VS4Mac does not fully support MAUI. It will be added in 17.1.

coolbluewater commented 2 years ago

@VladislavAntonyuk - Yes, that's correct. Do we know whether sqlite works using Visual Studio for Windows, which fully supports maui?

VladislavAntonyuk commented 2 years ago

Just checked, it works on Windows. To be honest it works on VS4Mac as well. You only need to restore packages using cli.

coolbluewater commented 2 years ago

@VladislavAntonyuk - thanks! Which packages? Any special instructions to restore? VsMac keeps restoring packages a lot. Do you see the same behavior?

VladislavAntonyuk commented 2 years ago

I first run dotnet restore. Than open VS4MAC and run build. In that case VS4MAC doesn't restore packages again. Seems like VS treats iOS and Mac catalyst as the same target framework during package restore.

Also it works on CI build because it uses dornet cli

coolbluewater commented 2 years ago

@VladislavAntonyuk thanks! Do you still need to change the os version for the maccatalyst target?

VladislavAntonyuk commented 2 years ago

yes, 15.2 is the minimum supported version

ericsink commented 2 years ago

Version 2.1.0 is on nuget. Any further maccatalyst-specific problems, please open a new issue.

edoust commented 2 years ago

I am still having the exact same issue with v2.1.0... :(

ericsink commented 2 years ago

I believe the latest status of this was that it works fine on the command line but doesn't work with Visual Studio for Mac. @edoust Is that true for you?

If so, that means your problem is possibly related to #489

edoust commented 2 years ago

No, I am doing a CLI build with this command - it does not change the problem whether I do it in VS or using dotnet

dotnet build %(SolutionFile) --framework net6.0-maccatalyst15.4

Will keep an eye on it, for now I am still using your preview package alongside the custom nuget that contains your native lib

ericsink commented 2 years ago

@edoust If you can construct a minimal repro project, please open a new issue and post it there.

edoust commented 2 years ago

Yes, will do it these days