Skip to content

Commit 81107a4

Browse files
committed
Mac Catalyst basic support
1 parent d147f81 commit 81107a4

9 files changed

Lines changed: 55 additions & 13 deletions

File tree

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/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: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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");

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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<TargetFrameworks>net8.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</TargetFrameworks>
99

1010
<OutputType>Exe</OutputType>
1111
<RootNamespace>MAUITodo</RootNamespace>
@@ -32,6 +32,7 @@
3232
<MauiVersion>8.0.90</MauiVersion>
3333

3434
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
35+
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</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>

demos/MAUITodo/Platforms/MacCatalyst/Info.plist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>NSAppTransportSecurity</key>
6+
<dict>
7+
<key>NSExceptionDomains</key>
8+
<dict>
9+
<key>localhost</key>
10+
<dict>
11+
<key>NSExceptionAllowsInsecureHTTPLoads</key>
12+
<true/>
13+
</dict>
14+
</dict>
15+
</dict>
516
<key>UIDeviceFamily</key>
617
<array>
718
<integer>1</integer>

demos/MAUITodo/Views/ListsPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Title="Todo Lists">
66
<ContentPage.ToolbarItems>
77
<ToolbarItem x:Name="WifiStatusItem"
8-
Order="Primary"
8+
Order="Primary"
99
Priority="0"/>
1010
</ContentPage.ToolbarItems>
1111

0 commit comments

Comments
 (0)