Skip to content
Merged
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
6 changes: 4 additions & 2 deletions PowerSync/PowerSync.Common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# PowerSync.Common Changelog

## 0.1.2-dev.1
## 0.1.2

- Fix `net9.0-android` and `net9.0-ios` not being in TargetFrameworks.
- Add support for MacCatalyst.
- Add support for .NET 9.0. Supported targets now also include `net9.0`, `net9.0-android`, `net9.0-ios`, and `net9.0-maccatalyst`.
- Update the PowerSync SQLite core extension to 0.4.13.

## 0.1.1

Expand Down
6 changes: 3 additions & 3 deletions PowerSync/PowerSync.Common/PowerSync.Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0;net8.0-ios;net8.0-android;net9.0-ios;net9.0-android</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0;net8.0-ios;net8.0-android;net8.0-maccatalyst;net9.0-ios;net9.0-android;net9.0-maccatalyst</TargetFrameworks>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -45,14 +45,14 @@

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

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

Expand Down
6 changes: 4 additions & 2 deletions PowerSync/PowerSync.Maui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# PowerSync.Maui Changelog

## 0.1.2-dev.1
## 0.1.2

- Fix `net9.0-android` and `net9.0-ios` not being in TargetFrameworks.
- Add support for MacCatalyst.
- Add support for .NET 9.0. Supported targets now also include `net9.0`, `net9.0-android`, `net9.0-ios`, and `net9.0-maccatalyst`.
- Upstream PowerSync.Common version bump (See Powersync.Common changelog 0.1.2 for more information)

## 0.1.1

Expand Down
11 changes: 10 additions & 1 deletion PowerSync/PowerSync.Maui/PowerSync.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0;net8.0-ios;net8.0-android;net9.0-ios;net9.0-android</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0;net8.0-ios;net8.0-android;net8.0-maccatalyst;net9.0-ios;net9.0-android;net9.0-maccatalyst</TargetFrameworks>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -45,6 +45,15 @@
</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
Expand Down
13 changes: 7 additions & 6 deletions PowerSync/PowerSync.Maui/SQLite/MAUISQLiteAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace PowerSync.Maui.SQLite;

using PowerSync.Common.MDSQLite;

// iOS specific imports
#if IOS
// iOS/MacCatalyst specific imports
#if IOS || MACCATALYST
using Foundation;
#endif

Expand All @@ -19,18 +19,18 @@ protected override void LoadExtension(SqliteConnection db)
{
db.EnableExtensions(true);

#if IOS
LoadExtensionIOS(db);
#if IOS || MACCATALYST
LoadExtensionApple(db);
#elif ANDROID
db.LoadExtension("libpowersync");
#else
base.LoadExtension(db);
#endif
}

private void LoadExtensionIOS(SqliteConnection db)
private void LoadExtensionApple(SqliteConnection db)
{
#if IOS
#if IOS || MACCATALYST
var bundlePath = Foundation.NSBundle.FromIdentifier("co.powersync.sqlitecore")?.BundlePath;
if (bundlePath == null)
{
Expand All @@ -48,3 +48,4 @@ private void LoadExtensionIOS(SqliteConnection db)
#endif
}
}

41 changes: 39 additions & 2 deletions Tools/Setup/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// </summary>
public class PowerSyncSetup
{
private const string VERSION = "0.4.12";
private const string VERSION = "0.4.13";

private const string GITHUB_BASE_URL = $"https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v{VERSION}";
private const string MAVEN_BASE_URL = $"https://repo1.maven.org/maven2/com/powersync/powersync-sqlite-core/{VERSION}";
Expand All @@ -31,6 +31,7 @@ public async Task RunSetup()
await SetupDesktop();
await SetupMauiIos();
await SetupMauiAndroid();
await SetupMauiMacCatalyst();
}
finally
{
Expand Down Expand Up @@ -127,6 +128,19 @@ public async Task SetupMauiAndroid()
}
}

public async Task SetupMauiMacCatalyst()
{
Console.WriteLine("Setting up MAUI MacCatalyst libraries...");

var nativeDir = Path.Combine(_basePath, "PowerSync.Maui", "Platforms", "MacCatalyst", "NativeLibs");
var config = new ArchiveConfig(
"powersync-sqlite-core.xcframework.zip",
"powersync-sqlite-core.xcframework"
);

await ProcessArchiveDownload(nativeDir, config, GITHUB_BASE_URL);
}

private void ExtractAarNativeLibraries(string aarPath, string nativeDir)
{
var extractedDir = Path.Combine(nativeDir, "temp_extracted");
Expand Down Expand Up @@ -185,7 +199,7 @@ private async Task ProcessArchiveDownload(string nativeDir, ArchiveConfig config
if (Directory.Exists(extractedPath))
Directory.Delete(extractedPath, recursive: true);

ZipFile.ExtractToDirectory(downloadPath, nativeDir);
ExtractZipPreservingSymlinks(downloadPath, nativeDir);
File.Delete(downloadPath);

Console.WriteLine($"✓ Extracted {config.ArchiveFileName} → {config.ExtractedName}");
Expand All @@ -196,6 +210,29 @@ private async Task ProcessArchiveDownload(string nativeDir, ArchiveConfig config
}
}

private static void ExtractZipPreservingSymlinks(string zipPath, string destDir)
{
// ZipFile.ExtractToDirectory does not preserve symlinks, which breaks
// macOS/Catalyst .xcframework bundles. Use `unzip` on Unix instead.
if (!OperatingSystem.IsWindows())
{
var proc = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
{
FileName = "unzip",
ArgumentList = { "-o", zipPath, "-d", destDir },
RedirectStandardOutput = true,
RedirectStandardError = true,
})!;
proc.WaitForExit();
if (proc.ExitCode != 0)
throw new Exception($"unzip exited with code {proc.ExitCode}: {proc.StandardError.ReadToEnd()}");
}
else
{
ZipFile.ExtractToDirectory(zipPath, destDir);
}
}

private async Task DownloadFile(string url, string outputPath)
{
Console.WriteLine($"📥 Downloading: {Path.GetFileName(outputPath)}");
Expand Down
2 changes: 1 addition & 1 deletion demos/CommandLine/CommandLine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>0.0.1</Version>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>12</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
6 changes: 6 additions & 0 deletions demos/MAUITodo/Data/NodeConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ public NodeConnector()
// Load or generate User ID
UserId = LoadOrGenerateUserId();

// Android emulator uses 10.0.2.2 to access host-ran processes
#if ANDROID
BackendUrl = "http://10.0.2.2:6060";
PowerSyncUrl = "http://10.0.2.2:8080";
#else
BackendUrl = "http://localhost:6060";
PowerSyncUrl = "http://localhost:8080";
#endif

clientId = null;
}
Expand Down
7 changes: 4 additions & 3 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</TargetFrameworks>
<TargetFrameworks>net8.0-android;net9.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>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>

<OutputType>Exe</OutputType>
<RootNamespace>MAUITodo</RootNamespace>
Expand All @@ -31,7 +31,8 @@

<MauiVersion>8.0.90</MauiVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</TargetPlatformMinVersion>
Expand Down
10 changes: 10 additions & 0 deletions demos/MAUITodo/Platforms/MacCatalyst/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
2 changes: 2 additions & 0 deletions demos/MAUITodo/Platforms/MacCatalyst/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
<key>UIUserInterfaceStyle</key>
<string>Light</string>
</dict>
</plist>
15 changes: 5 additions & 10 deletions demos/MAUITodo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Changes made to the backend's source DB or to the self-hosted web UI will be syn
In the repo root, run the following to download the PowerSync extension:

```bash
dotnet run --project Tools/Setup
dotnet run --project Tools/Setup
```

Then switch into the demo's directory:
Expand All @@ -31,6 +31,7 @@ dotnet build -t:Run -f:net8.0-ios
```

Specifyng an iOS simulator

```sh
dotnet build -t:Run -f:net8.0-ios -p:_DeviceName=:v2:udid=B1CA156A-56FC-4C3C-B35D-4BC349111FDF
```
Expand All @@ -42,19 +43,13 @@ dotnet build -t:Run -f:net8.0-android
```

Specifying an Android emulator

```sh
dotnet build -t:Run -f:net8.0-android -p:_DeviceName=emulator-5554
```

### Windows
### MacCatalyst

```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.
dotnet build -t:Run -f:net8.0-maccatalyst
```
BackendUrl = "http://10.0.2.2:6060";
PowerSyncUrl = "http://10.0.2.2:8080";
```
2 changes: 1 addition & 1 deletion demos/MAUITodo/Views/ListsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Title="Todo Lists">
<ContentPage.ToolbarItems>
<ToolbarItem x:Name="WifiStatusItem"
Order="Primary"
Order="Primary"
Priority="0"/>
</ContentPage.ToolbarItems>

Expand Down