Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 13 additions & 5 deletions .github/workflows/dev-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ on: workflow_dispatch
jobs:
dev-release:
name: Publish Dev Packages
runs-on: windows-latest
runs-on: macos-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0'
dotnet-version: '8.0'

- name: Install MAUI Workloads
run: dotnet workload restore

- name: Download PowerSync extension
run: dotnet run --project Tools/Setup
Expand All @@ -37,7 +42,7 @@ jobs:

- name: Run Push For Common
continue-on-error: true
run: dotnet nuget push ${{ github.workspace }}\output\PowerSync.Common*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ${{ github.workspace }}/output/PowerSync.Common*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}

- name: Extract MAUI Package Version from CHANGELOG.md
id: extract_maui_version
Expand All @@ -46,10 +51,13 @@ jobs:
MAUI_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+-dev(\.[0-9]+)?$/ {print $2; exit}' PowerSync/PowerSync.Maui/CHANGELOG.md)
echo "Detected Version: $MAUI_VERSION"
echo "VERSION=$MAUI_VERSION" >> $GITHUB_ENV


- name: Build MAUI Project
run: dotnet build PowerSync/PowerSync.Maui -c Release

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

- name: Run Push For MAUI
continue-on-error: true
run: dotnet nuget push ${{ github.workspace }}\output\PowerSync.Maui*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ${{ github.workspace }}/output/PowerSync.Maui*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
16 changes: 12 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@ on: workflow_dispatch
jobs:
release:
name: Release
runs-on: windows-latest
runs-on: macos-latest
if: github.ref == 'refs/heads/main'

steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0'
dotnet-version: '8.0'

- name: Install MAUI Workloads
run: dotnet workload restore

- name: Download PowerSync extension
run: dotnet run --project Tools/Setup
Expand All @@ -37,7 +42,7 @@ jobs:

- name: Run Push for Common
continue-on-error: true
run: dotnet nuget push ${{ github.workspace }}\output\PowerSync.Common*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ${{ github.workspace }}/output/PowerSync.Common*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}

- name: Extract MAUI Package Version from CHANGELOG.md
id: extract_maui_version
Expand All @@ -46,10 +51,13 @@ jobs:
MAUI_VERSION=$(awk '/^## [0-9]+\.[0-9]+\.[0-9]+/ {print $2; exit}' PowerSync/PowerSync.Maui/CHANGELOG.md)
echo "Detected Version: $MAUI_VERSION"
echo "VERSION=$MAUI_VERSION" >> $GITHUB_ENV

- name: Build MAUI Project
run: dotnet build PowerSync/PowerSync.Maui -c Release

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

- name: Run Push For MAUI
continue-on-error: true
run: dotnet nuget push ${{ github.workspace }}\output\PowerSync.Maui*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ${{ github.workspace }}/output/PowerSync.Maui*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }}
3 changes: 3 additions & 0 deletions PowerSync/PowerSync.Common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# PowerSync.Common Changelog

## 0.0.4-alpha.1
- Fixed MAUI issues related to extension loading when installing package outside of the monorepo.

## 0.0.3-alpha.1
- Minor changes to accommodate PowerSync.MAUI package extension.

Expand Down
9 changes: 7 additions & 2 deletions PowerSync/PowerSync.Common/PowerSync.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
<PackageReference Include="System.Threading.Channels" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<None Include="PowerSync.Common.targets" Pack="true" PackagePath="build\" />
<None Include="PowerSync.Common.targets" Pack="true" PackagePath="buildTransitive\" />
</ItemGroup>

<!-- Check allows us to skip for all MAUI targets-->
<!-- For monorepo-->
<ItemGroup Condition="!$(TargetFramework.Contains('-'))">
<ItemGroup Condition="!$(TargetFramework.EndsWith('-android')) AND !$(TargetFramework.EndsWith('-ios'))">
<Content Include="runtimes\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<!-- For releasing runtimes -->
<ItemGroup Condition="!$(TargetFramework.Contains('-'))">
<ItemGroup Condition="!$(TargetFramework.EndsWith('-android')) AND !$(TargetFramework.EndsWith('-ios'))">
<None Include="runtimes\**\*.*" Pack="true" PackagePath="runtimes\" />
</ItemGroup>

Expand Down
7 changes: 7 additions & 0 deletions PowerSync/PowerSync.Common/PowerSync.Common.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project>
<Target Name="RemovePowerSyncNativeForAndroid" AfterTargets="ResolvePackageAssets" Condition="$(TargetFramework.Contains('android'))">
<ItemGroup>
<NativeCopyLocalItems Remove="@(NativeCopyLocalItems)" Condition="'%(NuGetPackageId)' == 'PowerSync.Common'" />
</ItemGroup>
</Target>
</Project>
3 changes: 3 additions & 0 deletions PowerSync/PowerSync.Maui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# PowerSync.Maui Changelog

## 0.0.2-alpha.1
- Fixed issues related to extension loading when installing package outside of the monorepo.

## 0.0.1-alpha.1

- Introduce package. Support for iOS/Android use cases.
Expand Down
27 changes: 9 additions & 18 deletions PowerSync/PowerSync.Maui/PowerSync.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<PackageIcon>icon.png</PackageIcon>
<NoWarn>NU5100</NoWarn>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IsBindingProject>true</IsBindingProject>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeBuildOutput>true</IncludeBuildOutput>
</PropertyGroup>

<ItemGroup>
Expand All @@ -32,26 +35,14 @@
<SubType>Designer</SubType>
</None>
</ItemGroup>

<!-- For monorepo-->
<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<Content Include="Platforms\Android\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
<Content Include="Platforms\iOS\NativeLibs\powersync-sqlite-core.xcframework\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<!-- For releasing runtimes -->
<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
<None Include="Platforms\Android\**\*.*" Pack="true" PackagePath="Platforms\Android" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
<None Include="Platforms\iOS\NativeLibs\powersync-sqlite-core.xcframework\**\*.*" Pack="true" PackagePath="Platforms\iOS" />
<ObjcBindingApiDefinition Include="build\ApiDefinition.cs" />

<NativeReference Include="platforms\iOS\NativeLibs\powersync-sqlite-core.xcframework">
<Kind>Framework</Kind>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>
</Project>
17 changes: 11 additions & 6 deletions PowerSync/PowerSync.Maui/SQLite/MAUISQLiteAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override void LoadExtension(SqliteConnection db)
db.EnableExtensions(true);

#if IOS
LoadExtensionIOS(db);
LoadExtensionIOS(db);
#elif ANDROID
db.LoadExtension("libpowersync");
#else
Expand All @@ -29,16 +29,21 @@ protected override void LoadExtension(SqliteConnection db)

private void LoadExtensionIOS(SqliteConnection db)
{
#if IOS
var bundlePath = Foundation.NSBundle.MainBundle.BundlePath;
#if IOS
var bundlePath = Foundation.NSBundle.FromIdentifier("co.powersync.sqlitecore")?.BundlePath;
if (bundlePath == null)
{
throw new Exception("Could not find PowerSync SQLite extension bundle path");
}

var filePath =
Path.Combine(bundlePath, "Frameworks", "powersync-sqlite-core.framework", "powersync-sqlite-core");
Path.Combine(bundlePath, "powersync-sqlite-core");

using var loadExtension = db.CreateCommand();
loadExtension.CommandText = "SELECT load_extension(@path, @entryPoint)";
loadExtension.Parameters.AddWithValue("@path", filePath);
loadExtension.Parameters.AddWithValue("@entryPoint", "sqlite3_powersync_init");
loadExtension.ExecuteNonQuery();
#endif
#endif
}
}
4 changes: 4 additions & 0 deletions PowerSync/PowerSync.Maui/build/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace YourNamespace
{
// Empty API definition - allows xcframework to be included without managed bindings
}
11 changes: 9 additions & 2 deletions demos/MAUITodo/MAUITodo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<ApplicationId>com.companyname.todo</ApplicationId>

<TargetFrameworks>net8.0-android;net8.0-ios</TargetFrameworks>
<TargetFrameworks>net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>

<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-ios</TargetFrameworks>

<OutputType>Exe</OutputType>
<RootNamespace>MAUITodo</RootNamespace>
Expand Down Expand Up @@ -34,6 +34,13 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</TargetPlatformMinVersion>
</PropertyGroup>

<!-- Potentially only needed for net8.0-ios: https://github.com/microsoft/appcenter-sdk-dotnet/issues/1755#issuecomment-2373256340 -->
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-ios|AnyCPU'">
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<ForceSimulatorX64ArchitectureInIDE>true</ForceSimulatorX64ArchitectureInIDE>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
Expand Down
7 changes: 7 additions & 0 deletions demos/MAUITodo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,11 @@ dotnet build -t:Run -f:net8.0-android -p:_DeviceName=emulator-5554

```sh
dotnet run -f net8.0-windows10.0.19041.0
```

## Android on Windows
You may need to overwrite the [backend and PowerSync URLs](./Data/NodeConnector.cs) when running an Android emulator on Windows.
```
BackendUrl = "http://10.0.2.2:6060";
PowerSyncUrl = "http://10.0.2.2:8080";
```
Loading