Skip to content

Commit f4705ee

Browse files
authored
Mac catalyst support and .NET 9.0 support in demos (#64)
1 parent 9c4141d commit f4705ee

13 files changed

Lines changed: 94 additions & 29 deletions

File tree

PowerSync/PowerSync.Common/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## 0.1.2
44

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

79
## 0.1.1
810

PowerSync/PowerSync.Common/PowerSync.Common.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0;net8.0-ios;net8.0-android;net9.0-ios;net9.0-android</TargetFrameworks>
4+
<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>
55
<LangVersion>12</LangVersion>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
@@ -45,14 +45,14 @@
4545

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

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

PowerSync/PowerSync.Maui/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## 0.1.2
44

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

79
## 0.1.1
810

PowerSync/PowerSync.Maui/PowerSync.Maui.csproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;net6.0;net8.0;net9.0;net8.0-ios;net8.0-android;net9.0-ios;net9.0-android</TargetFrameworks>
4+
<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>
55
<LangVersion>12</LangVersion>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
@@ -45,6 +45,15 @@
4545
</NativeReference>
4646
</ItemGroup>
4747

48+
<ItemGroup Condition="$(TargetFramework.Contains('-maccatalyst'))">
49+
<ObjcBindingApiDefinition Include="build\ApiDefinition.cs" />
50+
51+
<NativeReference Include="Platforms\MacCatalyst\NativeLibs\powersync-sqlite-core.xcframework">
52+
<Kind>Framework</Kind>
53+
<SmartLink>False</SmartLink>
54+
</NativeReference>
55+
</ItemGroup>
56+
4857
<!-- Prevent e_sqlite3.a from being frozen into the binding manifest. It is provided by
4958
SQLitePCLRaw.lib.e_sqlite3.ios with separate device/simulator variants, selected at
5059
consuming-project build time via buildTransitive targets. Capturing it here would bake

PowerSync/PowerSync.Maui/SQLite/MAUISQLiteAdapter.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ namespace PowerSync.Maui.SQLite;
44

55
using PowerSync.Common.MDSQLite;
66

7-
// iOS specific imports
8-
#if IOS
7+
// iOS/MacCatalyst specific imports
8+
#if IOS || MACCATALYST
99
using Foundation;
1010
#endif
1111

@@ -19,18 +19,18 @@ protected override void LoadExtension(SqliteConnection db)
1919
{
2020
db.EnableExtensions(true);
2121

22-
#if IOS
23-
LoadExtensionIOS(db);
22+
#if IOS || MACCATALYST
23+
LoadExtensionApple(db);
2424
#elif ANDROID
2525
db.LoadExtension("libpowersync");
2626
#else
2727
base.LoadExtension(db);
2828
#endif
2929
}
3030

31-
private void LoadExtensionIOS(SqliteConnection db)
31+
private void LoadExtensionApple(SqliteConnection db)
3232
{
33-
#if IOS
33+
#if IOS || MACCATALYST
3434
var bundlePath = Foundation.NSBundle.FromIdentifier("co.powersync.sqlitecore")?.BundlePath;
3535
if (bundlePath == null)
3636
{
@@ -48,3 +48,4 @@ private void LoadExtensionIOS(SqliteConnection db)
4848
#endif
4949
}
5050
}
51+

Tools/Setup/Setup.cs

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/// </summary>
1111
public class PowerSyncSetup
1212
{
13-
private const string VERSION = "0.4.12";
13+
private const string VERSION = "0.4.13";
1414

1515
private const string GITHUB_BASE_URL = $"https://github.com/powersync-ja/powersync-sqlite-core/releases/download/v{VERSION}";
1616
private const string MAVEN_BASE_URL = $"https://repo1.maven.org/maven2/com/powersync/powersync-sqlite-core/{VERSION}";
@@ -31,6 +31,7 @@ public async Task RunSetup()
3131
await SetupDesktop();
3232
await SetupMauiIos();
3333
await SetupMauiAndroid();
34+
await SetupMauiMacCatalyst();
3435
}
3536
finally
3637
{
@@ -127,6 +128,19 @@ public async Task SetupMauiAndroid()
127128
}
128129
}
129130

131+
public async Task SetupMauiMacCatalyst()
132+
{
133+
Console.WriteLine("Setting up MAUI MacCatalyst libraries...");
134+
135+
var nativeDir = Path.Combine(_basePath, "PowerSync.Maui", "Platforms", "MacCatalyst", "NativeLibs");
136+
var config = new ArchiveConfig(
137+
"powersync-sqlite-core.xcframework.zip",
138+
"powersync-sqlite-core.xcframework"
139+
);
140+
141+
await ProcessArchiveDownload(nativeDir, config, GITHUB_BASE_URL);
142+
}
143+
130144
private void ExtractAarNativeLibraries(string aarPath, string nativeDir)
131145
{
132146
var extractedDir = Path.Combine(nativeDir, "temp_extracted");
@@ -185,7 +199,7 @@ private async Task ProcessArchiveDownload(string nativeDir, ArchiveConfig config
185199
if (Directory.Exists(extractedPath))
186200
Directory.Delete(extractedPath, recursive: true);
187201

188-
ZipFile.ExtractToDirectory(downloadPath, nativeDir);
202+
ExtractZipPreservingSymlinks(downloadPath, nativeDir);
189203
File.Delete(downloadPath);
190204

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

213+
private static void ExtractZipPreservingSymlinks(string zipPath, string destDir)
214+
{
215+
// ZipFile.ExtractToDirectory does not preserve symlinks, which breaks
216+
// macOS/Catalyst .xcframework bundles. Use `unzip` on Unix instead.
217+
if (!OperatingSystem.IsWindows())
218+
{
219+
var proc = System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
220+
{
221+
FileName = "unzip",
222+
ArgumentList = { "-o", zipPath, "-d", destDir },
223+
RedirectStandardOutput = true,
224+
RedirectStandardError = true,
225+
})!;
226+
proc.WaitForExit();
227+
if (proc.ExitCode != 0)
228+
throw new Exception($"unzip exited with code {proc.ExitCode}: {proc.StandardError.ReadToEnd()}");
229+
}
230+
else
231+
{
232+
ZipFile.ExtractToDirectory(zipPath, destDir);
233+
}
234+
}
235+
199236
private async Task DownloadFile(string url, string outputPath)
200237
{
201238
Console.WriteLine($"📥 Downloading: {Path.GetFileName(outputPath)}");

demos/CommandLine/CommandLine.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<Version>0.0.1</Version>
6-
<TargetFramework>net8.0</TargetFramework>
6+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
77
<LangVersion>12</LangVersion>
88
<ImplicitUsings>enable</ImplicitUsings>
99
<Nullable>enable</Nullable>

demos/MAUITodo/Data/NodeConnector.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ public NodeConnector()
2525
// Load or generate User ID
2626
UserId = LoadOrGenerateUserId();
2727

28+
// Android emulator uses 10.0.2.2 to access host-ran processes
29+
#if ANDROID
30+
BackendUrl = "http://10.0.2.2:6060";
31+
PowerSyncUrl = "http://10.0.2.2:8080";
32+
#else
2833
BackendUrl = "http://localhost:6060";
2934
PowerSyncUrl = "http://localhost:8080";
35+
#endif
3036

3137
clientId = null;
3238
}

demos/MAUITodo/MAUITodo.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<PropertyGroup>
44
<ApplicationId>com.companyname.todo</ApplicationId>
55

6-
<TargetFrameworks>net8.0-android</TargetFrameworks>
6+
<TargetFrameworks>net8.0-android;net9.0-android</TargetFrameworks>
77
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
8-
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-ios</TargetFrameworks>
8+
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('osx'))">$(TargetFrameworks);net8.0-ios;net8.0-maccatalyst;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
99

1010
<OutputType>Exe</OutputType>
1111
<RootNamespace>MAUITodo</RootNamespace>
@@ -31,7 +31,8 @@
3131

3232
<MauiVersion>8.0.90</MauiVersion>
3333

34-
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
34+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
35+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
3536
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
3637
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</SupportedOSPlatformVersion>
3738
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</TargetPlatformMinVersion>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.app-sandbox</key>
6+
<true/>
7+
<key>com.apple.security.network.client</key>
8+
<true/>
9+
</dict>
10+
</plist>

0 commit comments

Comments
 (0)