Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions .github/workflows/dev-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
dotnet-version: "10.0.x"

- name: Install MAUI Workloads
- name: Install native workloads
run: dotnet workload restore

- name: Download PowerSync extension
Expand All @@ -33,9 +33,6 @@ jobs:
- name: Restore dependencies
run: dotnet restore

- name: Install Android SDK for net8.0-android
run: dotnet build PowerSync/PowerSync.Common -t:InstallAndroidDependencies -f net8.0-android -p:AndroidSdkDirectory="$ANDROID_HOME" -p:AcceptAndroidSdkLicenses=True

- name: Extract Common Package Version from CHANGELOG.md
shell: bash
run: |
Expand All @@ -50,20 +47,6 @@ jobs:
- name: Run Pack For Common
run: dotnet pack PowerSync/PowerSync.Common -c Release -o ${{ github.workspace }}/output

- name: Extract MAUI Package Version from CHANGELOG.md
shell: bash
run: |
MAUI_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.Maui/CHANGELOG.md)
if [[ -z "$MAUI_VERSION" ]]; then
echo "Error: Invalid dev version found in PowerSync.Maui/CHANGELOG.md. Expected format: x.x.x-dev.x"
exit 1
fi
echo "Detected Version: $MAUI_VERSION"
echo "VERSION=$MAUI_VERSION" >> $GITHUB_ENV

- name: Run Pack For MAUI
run: dotnet pack PowerSync/PowerSync.Maui -c Release -o ${{ github.workspace }}/output

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -90,7 +73,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
dotnet-version: "10.0.x"

- name: Install Sign CLI tool
run: dotnet tool install --tool-path . --prerelease sign
Expand Down Expand Up @@ -142,7 +125,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
dotnet-version: "10.0.x"

- name: Validate artifact signatures
run: dotnet nuget verify ${{ github.workspace }}/SignedArtifacts/**/*.nupkg
Expand All @@ -158,9 +141,3 @@ jobs:
dotnet nuget push "${{ github.workspace }}\SignedArtifacts\PowerSync.Common*.nupkg"
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}"
--source https://api.nuget.org/v3/index.json

- name: Run Push For Maui
run: >
dotnet nuget push "${{ github.workspace }}\SignedArtifacts\PowerSync.Maui*.nupkg"
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}"
--source https://api.nuget.org/v3/index.json
47 changes: 3 additions & 44 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:

outputs:
common_version: ${{ steps.extract_version.outputs.common_version }}
maui_version: ${{ steps.extract_maui_version.outputs.maui_version }}

steps:
- name: Checkout Repository
Expand All @@ -28,7 +27,7 @@ jobs:
with:
dotnet-version: "10.0.x"

- name: Install MAUI Workloads
- name: Install native workloads
run: dotnet workload restore

- name: Download PowerSync extension
Expand All @@ -37,9 +36,6 @@ jobs:
- name: Restore dependencies
run: dotnet restore

- name: Install Android SDK for net8.0-android
run: dotnet build PowerSync/PowerSync.Common -t:InstallAndroidDependencies -f net8.0-android -p:AndroidSdkDirectory="$ANDROID_HOME" -p:AcceptAndroidSdkLicenses=True

- name: Extract Common Package Version from CHANGELOG.md
id: extract_version
shell: bash
Expand All @@ -56,22 +52,6 @@ jobs:
- name: Run Pack For Common
run: dotnet pack PowerSync/PowerSync.Common -c Release -o ${{ github.workspace }}/output

- name: Extract MAUI Package Version from CHANGELOG.md
id: extract_maui_version
shell: bash
run: |
MAUI_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/ {print $2; exit}' PowerSync/PowerSync.Maui/CHANGELOG.md)
if [[ -z "$MAUI_VERSION" ]]; then
echo "Error: Invalid version found in PowerSync.Maui/CHANGELOG.md. Expected format: '## x.x.x'"
exit 1
fi
echo "Detected Version: $MAUI_VERSION"
echo "VERSION=$MAUI_VERSION" >> $GITHUB_ENV
echo "maui_version=$MAUI_VERSION" >> $GITHUB_OUTPUT

- name: Run Pack For MAUI
run: dotnet pack PowerSync/PowerSync.Maui -c Release -o ${{ github.workspace }}/output

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -98,7 +78,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
dotnet-version: "10.0.x"

- name: Install Sign CLI tool
run: dotnet tool install --tool-path . --prerelease sign
Expand Down Expand Up @@ -150,7 +130,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
dotnet-version: "10.0.x"

- name: Validate artifact signatures
run: dotnet nuget verify ${{ github.workspace }}/SignedArtifacts/**/*.nupkg
Expand Down Expand Up @@ -181,24 +161,3 @@ jobs:
--target main \
--generate-notes \
SignedArtifacts/PowerSync.Common*.nupkg

- name: Run Push For Maui
run: >
dotnet nuget push "${{ github.workspace }}\SignedArtifacts\PowerSync.Maui*.nupkg"
--api-key "${{ steps.login.outputs.NUGET_API_KEY }}"
--source https://api.nuget.org/v3/index.json

- name: Create GitHub Release For Maui
continue-on-error: true
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
MAUI_VERSION: ${{ needs.build.outputs.maui_version }}
run: |
gh release create "PowerSync.Maui@${MAUI_VERSION}" \
--draft \
--title "PowerSync.Maui@${MAUI_VERSION}" \
--target main \
--generate-notes \
SignedArtifacts/PowerSync.Maui*.nupkg
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build:
strategy:
matrix:
matrix:
runner: [windows-latest, windows-11-arm]
name: Test Packages ${{ matrix.runner }}
runs-on: ${{ matrix.runner }}
Expand All @@ -18,16 +18,16 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0'
dotnet-version: "10.0"

- name: Install MAUI Workloads
- name: Install native workloads
run: dotnet workload restore

- name: Download PowerSync extension
run: dotnet run --project Tools/Setup
run: dotnet run --project Tools/Setup

- name: Restore dependencies
run: dotnet restore

- name: Run tests
run: dotnet test -v n --framework net10.0
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,8 @@ TestResults/
*.db-shm
*.db-wal

#Core binaries - add rules after ps extension downloading is supported
*.dylib
*.dll
*.so
*.xcframework
.env
*NativeLibs
# PowerSync runtimes installed by Tools/Setup
**/runtimes/

# Ignore user id file
user_id.txt
Expand Down
24 changes: 20 additions & 4 deletions PowerSync/PowerSync.Common/MDSQLite/MDSQLiteAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ namespace PowerSync.Common.MDSQLite;
using PowerSync.Common.DB;
using PowerSync.Common.Utils;

#if IOS || MACCATALYST
using Foundation;
#endif

public class MDSQLiteAdapterOptions()
{
public string Name { get; set; } = null!;
Expand Down Expand Up @@ -154,13 +158,25 @@ protected virtual void LoadExtensions(SqliteConnection db)

/// <summary>
/// Loads the bundled PowerSync core SQLite extension. Override on
/// platform-specific adapters (e.g. MAUI iOS/Android) where the native library
/// lives outside the desktop runtime path.
/// platform-specific adapters where the native library lives
/// outside the standard runtimes path.
/// </summary>
protected virtual void LoadDefaultPowerSyncExtension(SqliteConnection db)
{
var path = PowerSyncPathResolver.GetNativeLibraryPath(AppContext.BaseDirectory);
db.LoadExtension(path, "sqlite3_powersync_init");
string extensionPath;

#if IOS || MACCATALYST
var bundlePath =
NSBundle.FromIdentifier("co.powersync.sqlitecore")?.BundlePath
?? throw new Exception("Could not find PowerSync SQLite extension bundle path");
extensionPath = Path.Combine(bundlePath, "powersync-sqlite-core");
#elif ANDROID
extensionPath = "libpowersync";
#else
extensionPath = PowerSyncDesktopPathResolver.GetNativeLibraryPath(AppContext.BaseDirectory);
#endif

db.LoadExtension(extensionPath, "sqlite3_powersync_init");
}

public async Task Close()
Expand Down
36 changes: 25 additions & 11 deletions PowerSync/PowerSync.Common/PowerSync.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,40 @@
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
</ItemGroup>

<!-- For ProjectReference: copy the whole /runtimes/ directory. -->
<ItemGroup>
<None Include="PowerSync.Common.targets" Pack="true" PackagePath="build\" />
<None Include="PowerSync.Common.targets" Pack="true" PackagePath="buildTransitive\" />
<None Include="runtimes/**/*.*" Pack="true" PackagePath="runtimes/" />
</ItemGroup>

<!-- Check allows us to skip for all MAUI targets-->
<!-- For monorepo-->
<ItemGroup Condition="!$(TargetFramework.EndsWith('-android')) AND !$(TargetFramework.EndsWith('-ios')) AND !$(TargetFramework.EndsWith('-maccatalyst'))">
<Content Include="runtimes\**\*.*">
<!-- For NuGet-published package: only include the runtime directories for the current target. -->
<!-- Desktop -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == ''">
<Content Include="runtimes/win-*/**/*.*;runtimes/linux-*/**/*.*;runtimes/osx-*/**/*.*" Pack="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<!-- For releasing runtimes -->
<ItemGroup Condition="!$(TargetFramework.EndsWith('-android')) AND !$(TargetFramework.EndsWith('-ios')) AND !$(TargetFramework.EndsWith('-maccatalyst'))">
<None Include="runtimes\**\*.*" Pack="true" PackagePath="runtimes\" />
<!-- Apple -->
<!-- The .xcframework files under `/runtimes/ios` and `/runtimes/maccatalyst` are not interchangeable. -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'ios'">
<Content Include="runtimes/ios/native/*.xcframework.zip" Pack="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst'">
<Content Include="runtimes/maccatalyst/native/*.xcframework.zip" Pack="false">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<!-- Android -->
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'android'">
<AndroidNativeLibrary Include="runtimes/android-arm64/native/libpowersync.so" Abi="arm64-v8a" />
<AndroidNativeLibrary Include="runtimes/android-x64/native/libpowersync.so" Abi="x86_64" />
<AndroidNativeLibrary Include="runtimes/android-arm/native/libpowersync.so" Abi="armeabi-v7a" />
<AndroidNativeLibrary Include="runtimes/android-x86/native/libpowersync.so" Abi="x86" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\icon.png" Pack="true" PackagePath="" />
<None Include="../../icon.png" Pack="true" PackagePath="" />
<None Include="README.md" Pack="true" PackagePath="" />
</ItemGroup>
</Project>
7 changes: 0 additions & 7 deletions PowerSync/PowerSync.Common/PowerSync.Common.targets

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace PowerSync.Common.Utils;

using System.Runtime.InteropServices;

public static class PowerSyncPathResolver
public static class PowerSyncDesktopPathResolver
{
public static string GetNativeLibraryPath(string packagePath)
{
Expand Down
3 changes: 1 addition & 2 deletions PowerSync/PowerSync.Maui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

## 1.0.1

- Full release.
- Upstream PowerSync.Common version bump (See Powersync.Common changelog 1.0.1 for more information)
- ⚠️ Deprecate `PowerSync.Maui`. Use `PowerSync.Common` and `MDSQLiteAdapter` / `MDSQLiteDBOpenFactory` instead.

## 1.0.0 (unlisted)

Expand Down
39 changes: 1 addition & 38 deletions PowerSync/PowerSync.Maui/PowerSync.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net9.0;net10.0;net9.0-android;net10.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net9.0-ios;net10.0-ios;net9.0-maccatalyst;net10.0-maccatalyst</TargetFrameworks>
Expand All @@ -19,51 +18,15 @@
<PackageReleaseNotes>https://github.com/powersync-ja/powersync-dotnet/PowerSync/PowerSync.Maui/CHANGELOG.md</PackageReleaseNotes>
<PackageTags>powersync local-first local-storage state-management offline sql db persistence sqlite sync </PackageTags>
<PackageIcon>icon.png</PackageIcon>
<NoWarn>NU5100;1591</NoWarn>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IsBindingProject>true</IsBindingProject>
<IncludeBuildOutput>true</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\PowerSync.Common\PowerSync.Common.csproj" SetTargetFramework="TargetFramework=$(TargetFramework)" />
<ProjectReference Include="..\PowerSync.Common\PowerSync.Common.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\icon.png" Pack="true" PackagePath=""/>
<None Include="README.md" Pack="true" PackagePath=""/>
<None Update="Platforms\Android\Resources\values\colors.xml">
<SubType>Designer</SubType>
</None>
</ItemGroup>


<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
<ObjcBindingApiDefinition Include="build\ApiDefinition.cs" />

<NativeReference Include="platforms\iOS\NativeLibs\powersync-sqlite-core.xcframework">
<Kind>Framework</Kind>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-maccatalyst'))">
<ObjcBindingApiDefinition Include="build\ApiDefinition.cs" />

<NativeReference Include="Platforms\MacCatalyst\NativeLibs\powersync-sqlite-core.xcframework">
<Kind>Framework</Kind>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>

<!-- Prevent e_sqlite3.a from being frozen into the binding manifest. It is provided by
SQLitePCLRaw.lib.e_sqlite3.ios with separate device/simulator variants, selected at
consuming-project build time via buildTransitive targets. Capturing it here would bake
in the device-only variant and break simulator builds in consuming projects. -->
<Target Name="_RemoveE_Sqlite3FromBindingManifest" BeforeTargets="_SanitizeNativeReferences" Condition="'$(IsBindingProject)' == 'true'">
<ItemGroup>
<NativeReference Remove="@(NativeReference)" Condition="'%(Filename)' == 'e_sqlite3'" />
</ItemGroup>
</Target>

</Project>
Loading
Loading